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

  • 相关阅读:
    数据对拍
    学大伟业 Day 5 培训总结
    【luogu P3378 堆】 模板
    【luogu P1865 A % B Problem】 题解
    学大伟业 Day 4 培训总结
    【luogu P1082 同余方程】 题解
    诗一首
    【luogu P2251 质量检测】 题解
    【luogu P3865 ST表】 模板
    【luogu P1816 忠诚】 题解
  • 原文地址:https://www.cnblogs.com/no7dw/p/2048245.html
Copyright © 2011-2022 走看看