Silently catch windows error popups when calling LoadLibrary()

冷暖自知 提交于 2021-02-07 08:32:25

问题


Is it possible to silently catch errors popup like "the procedure entry point xxx could not be located int the dynamic link library xxx" when calling LoadLibrary() ?


回答1:


You can suppress the error popups by calling 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);

The call to LoadLibrary() will still fail, though.



来源:https://stackoverflow.com/questions/4058303/silently-catch-windows-error-popups-when-calling-loadlibrary

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!