2

我正在从我的 VB6 应用程序中调用 C dll。该 dll 具有如下的函数调用签名。

void WINAPI geterrstr(char* foo);

其中 foo 是必须返回的字符串。

在我的 VB6 应用程序中,我尝试使用以下语法调用我的 dll,但它返回一个空字符串。

Declare Sub geterrstr Lib "technopnp.dll" (ByRef lpbuffer As String)

有任何想法吗?

4

1 回答 1

5

你应该能够;

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

n需要适当的缓冲区大小,太短会崩溃。

于 2011-11-12T18:31:51.623 回答