一个为VB写的DLL,其中有一个LPSTR&参数输出结果信息,在VC里怎么做?

lifeforu 2004-08-13 12:01:28
typedef int (*TESTDLL)(LPSTR szHostName,int nPort,LPSTR& lpsMsg);
LPSTR strMsg;
if(lpproc!=(TESTDLL)NULL)
{
iResult = (*lpproc)( "192.168.1.6" , 5151 , strMsg);
MessageBox( 0 , strMsg , "DLL" , MB_OK);
}
这样做好像不行
VB里调用:
Dim sMsg As String * 200
lRetVal = eConnectServer(txtServer.Text, port, sMsg)

不能改DLL的情况一如何调用?
...全文
190 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
快乐鹦鹉 2004-08-13
  • 打赏
  • 举报
回复
好像不行啊
dim sMsg as String
然后将sMsg那个参数设置成byRef
lifeforu 2004-08-13
  • 打赏
  • 举报
回复
extern "C" int APIENTRY eConnectServer(LPSTR szHostName,int nPort,LPSTR& lpsMsg)
这是DLL函数声明语句,为什么这样的调用会出问题呢?
The value of ESP was not properly saved across a function call.
This is usually a result of calling a function declared with one calling convention with a function poionter declared with a different calling convention.
junccc 2004-08-13
  • 打赏
  • 举报
回复
同意happyparrot
typedef int (*TESTDLL)(LPSTR szHostName,int nPort,LPSTR& lpsMsg);
LPSTR strMsg=new char[200];
memset(strMsg,0,200);
if(lpproc!=(TESTDLL)NULL)
{
iResult = (*lpproc)( "192.168.1.6" , 5151 , strMsg);
MessageBox( 0 , strMsg , "DLL" , MB_OK);
}
delete [] strMsg;
快乐鹦鹉 2004-08-13
  • 打赏
  • 举报
回复
LPSTR strMsg;
这是一个指针类型。你没有分配空间。
在你的VB程序里面就分配空间了
lifeforu 2004-08-13
  • 打赏
  • 举报
回复
在VB里调用没有问题的,我是想问问在VC里该怎么调用

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧