문제

I'm getting the return value when I call ShellExecute - an integer. Where can I get the associated error messages? I know they're general, but I've seen messages in the MS documentation.

도움이 되었습니까?

해결책

The error handling for ShellExecute is something of a disaster. Raymond Chen discusses it here: Why does ShellExecute return SE_ERR_ACCESSDENIED for nearly everything? So, even if you can convert the handful of possible ShellExecute errors into text, you'll find that you invariably get Access denied. And that's not very helpful.

The bottom line is that if you want real error reporting then you need to use ShellExecuteEx. If that fails you call GetLastError to get the Win32 error. To turn it into an exception with the descriptive text, call RaiseLastOSError. If you just want the descriptive text associated with an error, you call SysErrorMessage.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top