Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shellexecute Return Value error messages

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.

like image 218
Patrick Moloney Avatar asked Feb 23 '13 15:02

Patrick Moloney


1 Answers

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.

like image 64
David Heffernan Avatar answered Sep 21 '22 11:09

David Heffernan