您的位置:首页 > 其它

VC学习到的东西

2009-05-25 15:24 344 查看
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!");
}

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  dll null