zoukankan      html  css  js  c++  java
  • Visual Basic 和 C++ 的 DLL 之间传递一个字符串的方法

    .cpp

      void __stdcall FillString(LPSTR pszString, LONG cSize)
    {
             
    // Create a temp buffer with our string
             char buffer[] = "Hello from the C DLL!";

             
    // Copy our temp string to pszString
             
    // but check the size to make sure we have a buffer
             
    // big enough to hold the entire string.
             if (cSize > strlen(buffer))
                strcpy(pszString, buffer);
    }

    .def(不可或缺的,之前一直少了这个,报很多奇怪的问题)

    LIBRARY StrSamp
          DESCRIPTION 
    'Microsoft KB Sample DLL'
          EXPORTS
             DisplayStringByVal
             DisplayStringByRef
             FillString
             InStrRev

    VB

    Private Declare Sub FillString Lib "StrSamp.dll" _
             (
    ByVal sMyString As StringByVal cBufferSize As Long)
    Private Sub Command2_Click()
             
    Dim sFillTest As String

             sFillTest 
    = Space$(260)
             FillString sFillTest, 
    260
             
    MsgBox Trim$(sFillTest), vbInformation, "Fill String"

    End Sub

    from:

    http://support.microsoft.com/kb/187912

  • 相关阅读:
    高精度乘法
    阶乘
    高精度减法
    高精度加法
    曹冲养猪
    采药2
    nginx.conf详解
    系统盘脚本扩容
    IDEA中编写脚本并运行shell脚本
    常用的pdf工具
  • 原文地址:https://www.cnblogs.com/no7dw/p/2048245.html
Copyright © 2011-2022 走看看