开发者

Silently catch windows error popups when calling LoadLibrary()

开发者 https://www.devze.com 2023-01-22 22:20 出处:网络
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() ?You can suppress t

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() ?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消