用CPP中的参数动态调用外部DLL
calling an external dll dynamically with parameters in cpp
我在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;
}
有什么想法我做错了什么?预先感谢!
我现在正常工作..我缺少定义的typedef中的额外参数:
typedef int (__cdecl *MYPROC)(CString a, CString b, CString c, BOOL d);
相关文章:
- 调用外部函数,无法指定类型 C++/MVS
- 加载由 MATLAB Coder 生成的带有函数的 DLL,该函数调用外部函数
- NASM 调用外部C++功能
- 如何调用外部程序并在 C/C++ 中获取多个返回值
- Adobe 字符串内存泄漏 - 在哪里调用外部库入口点以释放内存?
- 直接调用外部方法时的访问违规异常
- 如何在C 中调用外部模板功能
- 用CPP中的参数动态调用外部DLL
- 调用外部函数(从一个exe到另一个exe)
- 如何从node.js调用外部脚本/程序
- Unity3D调用外部dll
- 调用外部WinAPI函数
- 调用外部访问器函数时出错
- C 代码如何在没有前导下划线的情况下调用外部函数
- 调用外部代码
- 从类中创建一个信号来调用外部函数
- windows DLL函数调用外部exe文件无效
- 在内联函数中调用外部函数
- Visual Lisp:如何调用外部c++ DLL中的函数
- 以跨平台的方式在c++中调用外部文件(例如可执行文件)