1 CString 到const char* 类型转换:
......
CString str = "XXXXX";
const char* p_chr_const = (LPCTSTR)str;
......
2 dll显式加载
外部定义库中的函数
例如库中有一函数 void myfunction(const CString) 则,外部定义时为:
typedef void(_cdecl *MY1)(const CString);
其他步骤:
HINSTANCE hinstDLL = NULL;
hinstDLL=LoadLibrary("XXXXXX.dll");
if (hinstDLL != NULL)
{
MY1 myfun;
myfun = (MY2)GetProcAddress(hinstDLL, "myfunction");
.....中间省去myfun(即myfunction)函数的使用情况
FreeLibrary(hinstDLL);
}
else
{
AfxMessageBox("dll load failed!");
}
本文介绍了如何将CString类型转换为const char*类型,并详细展示了如何通过显式加载DLL来调用其中定义的函数。首先,提供了CString到const char*的具体转换代码;接着,通过示例演示了DLL的加载过程及如何获取并调用DLL中的函数。

4204

被折叠的 条评论
为什么被折叠?



