【发布时间】:2014-03-10 05:14:31
【问题描述】:
我有一个读取字符串并显示它的测试 dll 函数:
int _stdcall test(LPSTR myString) {
MessageBoxA(NULL, (LPCSTR)myString, "test", MB_OK);
return 0;}
excel VBA声明是
Declare Function test Lib "test.dll" (ByVal text As String) As Long
有一个调用该函数的子程序。它读取值为“abcde”的 excel 单元格,并能够显示正确的结果。子代码是:
sub testCode()
test (cells(1,1).value)
end sub
但是当使用excel公式=test(A1)调用dll函数时,消息框只显示字符串的第一个字符“a”。
我花了整个周末阅读 BSTR 等,仍然无法解决这个问题。这里发生了什么?
【问题讨论】: