VC调用DLL后,利用FreeLibrary释放该DLL时出错。
VC调用DLL后,利用FreeLibrary释放该DLL时出错。利用同样的程序调用另外的DLL没有类似错误。
但该DLL在VB中调用也没有出现过类似错误。怎么回事呢?
源码如下:
void CTestAPIDlg::OnOK()
{
HINSTANCE hDllFunc ;
typedef int (__stdcall *MyFunc)(UINT port,UINT AsyncProce,UINT BaudRate,UINT Parity,UINT DataBits,UINT StopBits);
MyFunc pFunc;
int li_ret;
CString ls_ret;
hDllFunc = LoadLibrary("DllName.dll") ;
if(hDllFunc != NULL)
{
pFunc = (MyFunc)GetProcAddress(hDllFunc,"_EnablePort@24");
if(pFunc!=(MyFunc)NULL)
{
li_ret=(*pFunc)(1,0,0,0,0,0);
ls_ret.Format("%d", li_ret);
MessageBox(ls_ret);
}
else
{
MessageBox("Get Function fail!");
}
FreeLibrary(hDllFunc) ;// 这句出错:"0x10002b1f"指令引用的"0x10002b1f"内存。该内存不能为"read"
}
else
{
MessageBox("Load DLL fail!");
}
}
—————————————————————————————————
┏━★━━◆━━★━┓
♂欢|◢CSDN◣|使♂ ▲自由保存帖子,浏览,关注检测
┃迎|◥论坛助手◤|用┃ ▲完善的CSDN客户端工具
┗━☆━━◇━━━☆┛ ▲自动添加签名......
让你更快,更爽,更方便地上CSDN...
http://www.csdn.net/expert/topic/573/573604.xml
http://www.chinaok.net/csdn/csdn.zip