谁能帮我改正错误,最好给个例子!两天没搞定了!
做dll传参数出错!
这是dll的!
extern "C" __declspec(dllexport) void Show(CString aa)
{
AfxMessageBox(aa);
}
这是调用!
void CTestDlg::OnOK()
{
// TODO: Add extra validation here
typedef void (WINAPI * TESTDLL)(CString aa);
HINSTANCE hmod;
hmod = ::LoadLibrary ("mfcdll.dll");
if(hmod==NULL)
{
AfxMessageBox("Fail");
}
TESTDLL lpproc;
CString aa="bb";
lpproc = (TESTDLL)GetProcAddress (hmod,"Show");
if(lpproc!=(TESTDLL)NULL)
(*lpproc)(aa);
FreeLibrary(hmod);
}
能调用dll 显示出来对话框!
但debug 的出现一个提示框
Program: D:\TESTDLL\test\Debug\test.exe
Module:
File: i386\chkesp.c
Line: 42
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 pointer declared with a different calling convention.
(Press Retry to debug the application)
而release的则自动关闭窗口
我想还是传的参数不能为cstring,或者类型不对,实在找不到问题了!:(