I have a Delphi console application that at the end needs to launch one of two applications.
I'm having some problems getting ShellExecute to work without erroring, and I think the problem is associated with not having a handle for the console applicaiton.
The line that is causing me grief is:
ShellExecute(0, 'open', 'someapplication.exe', nil, nil, SW_SHOWNORMAL);
I think that the 0 in the handle is the problem as it compiles OK and runs in the debugger OK, but if I try to run the executable I get an unhandled error (the console application thinks that it has finished happily).
Passing 0 for the hwnd
parameter is fine. The documentation describes the parameter thus:
A handle to the parent window used for displaying a UI or error messages. This value can be NULL if the operation is not associated with a window.
Your error is due to something else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With