LoadLirary函数调用DLL

msdn中的描述:

The LoadLibrary function maps the specified executable module into the address space of the calling process.

HINSTANCE LoadLibrary(LPCTSTR lpLibFileName);
Parameters
lpLibFileName
Pointer to a null-terminated string that names the executable module (either a .DLL or .EXE file). The name specified is the filename of the module and is not related to the name stored in the library module itself, as specified by the LIBRARY keyword in the module-definition (.DEF) file.

If the string specifies a path but the file does not exist in the specified directory, the function fails. When specifying a path, be sure to use backslashes (/), not forward slashes (/).

If the string does not specify a path, the function uses a standard search strategy to find the file. See the Remarks for more information.

Return Values

If the function succeeds, the return value is a handle to the module.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

说明:如果函数调用成功则返回一个句柄(32位无符号整型),并且句柄值大于32;如果函数调用失败则返回NULL,这时可以调用GetLastError()函数来获得扩展的错误信息。注意,如果LoadLibrary函数调用返回NULL,即函数调用失败,而此时调用GetLastError()函数得到的扩展错误信息为0时,最可能的原因是你自己的程序逻辑上有问题。应该仔细检查代码的逻辑。最常的情况是其他使用了该DLL中函数的线程发生了异常,导致DLL被自动释放。即,DLL刚被加载成功,随即又被释放,并由应用程序自身的代码将该DLL的句柄设置为NULL。以前我自己做的一个多线程服务器加载DLL就出现过这种现象,后来发现是采样线程中的一个函数错误导致的。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值