Per*_*etz 2 string vb6 dll function-calls
我从VB6应用程序调用C dll.dll具有如下函数调用签名.
void WINAPI geterrstr(char* foo);
Run Code Online (Sandbox Code Playgroud)
其中foo是必须返回的字符串.
在我的VB6应用程序中,我尝试使用以下语法调用我的dll,但它返回一个空字符串.
Declare Sub geterrstr Lib "technopnp.dll" (ByRef lpbuffer As String)
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
你应该能够;
Declare Sub geterrstr Lib "technopnp.dll" (ByVal lpbuffer As String)
...
dim buff as string
buff=string$(n, vbnullchar)
geterrstr buff
//read upto 1st vbnullchar
buff = left$(buff, instr(1, buff, vbnullchar) - 1)
if (buff="") then
//no data
else
msgbox buff
end if
Run Code Online (Sandbox Code Playgroud)
n 需要是一个合适的缓冲区大小,太短,它会崩溃.