Error handling for ShellExecute is a bit of a disaster. Raymond Chen discusses it here: Why does ShellExecute return SE_ERR_ACCESSDENIED for almost everything? So, even if you can convert several possible ShellExecute errors to text, you will always get Access denied . And it is not very useful.
The bottom line is that if you need real error reporting, you need to use ShellExecuteEx . If this fails, you call GetLastError to get a Win32 error. To turn it into a descriptive text exception, RaiseLastOSError . If you just need the descriptive text associated with the error, you call SysErrorMessage .
source share