winapi - 调用 LoadLibrary() 时静默捕获窗口错误弹出窗口

标签 winapi

是否可以在调用 LoadLibrary() 时静默捕获错误弹出窗口,例如“过程入口点 xxx 无法位于动态链接库 xxx 中”?

最佳答案

您可以通过调用 SetErrorMode() 来抑制错误弹出窗口:

// GetErrorMode() only exists on Vista and higher,
// call SetErrorMode() twice to achieve the same effect.
UINT oldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
SetErrorMode(oldErrorMode | SEM_FAILCRITICALERRORS);

HMODULE library = LoadLibrary("YourLibrary.dll");

// Restore previous error mode.
SetErrorMode(oldErrorMode);

调用 LoadLibrary()不过还是会失败。

关于winapi - 调用 LoadLibrary() 时静默捕获窗口错误弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4058303/

相关文章:

定期时间调整更改的 Windows 通知

multithreading - pthread_keycreate 中析构函数的 Win32 替代方案(当我无法控制 dllmain 时)

C++ 如何在 directx 中制作 GUI?

.net - 在 .NET 应用程序中使用 RegisterDeviceNotification

c++ - 调用 SHGetSpecialFolderLocation() 函数时,系统帐户和管理员帐户有什么不同?

c - 使用 GCC 和 MSVC 编译时的不同行为

c++ - 尝试在 Windows 上重新启动打印机后台处理程序时,“net start spooler”失败并显示退出代码 2

c++ - window : open a named document

c++ - 用输入框提示用户? [C++]

c# - 在哪里可以找到 Win32 API 中 ManagementObjectSearcher 中使用的所有表