我在 MSDN 上找到了这个例子,我正在尝试使用它,但我在让它与参数一起工作时遇到了问题(http://msdn.microsoft.com/en-us/library/ms686944(VS.85).aspx)
下面是我尝试使用的代码,我尝试调用的方法有 4 个参数(CString a、CString b、CString c、BOOL d)。
extern "C" __declspec(dllexport) int __stdcall
ImportFile(CString a, CString b, CString c, BOOL d)
{
HINSTANCE hinstLib;
MYPROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
// Get a handle to the DLL module.
hinstLib = LoadLibrary(TEXT("C:\MyDll.dll"));
// If the handle is valid, try to get the function address.
if (hinstLib != NULL)
{
ProcAdd = (MYPROC) GetProcAddress(hinstLib, "TestFunction");
// If the function address is valid, call the function.
if (NULL != ProcAdd)
{
fRunTimeLinkSuccess = TRUE;
(ProcAdd) (a, b, c, d);
}
// Free the DLL module.
fFreeResult = FreeLibrary(hinstLib);
}
// If unable to call the DLL function
if (!fRunTimeLinkSuccess)
return -1;
return 0;
}
任何想法我做错了什么?提前致谢!!!