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.
Asked
Active
Viewed 6,280 times
5
-
Take them from the [documentation](http://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx)? – BeniBela Feb 23 '13 at 15:28
-
...as [MS itself does](http://support.microsoft.com/kb/170918/en)... – TLama Feb 23 '13 at 15:34
1 Answers
8
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
.

Fred vdP
- 103
- 5

David Heffernan
- 601,492
- 42
- 1,072
- 1,490