Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it OK to pass a null window handle to ShellExecute?

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).

like image 813
Dan Kelly Avatar asked Feb 24 '12 11:02

Dan Kelly


1 Answers

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.

like image 96
David Heffernan Avatar answered Nov 01 '22 23:11

David Heffernan