PDA

Click to See Complete Forum and Search --> : ShellExecute Equals the Meaning of Life


barrie
Nov 9th, 1999, 09:57 PM
From my research I have found that the ShellExecute WindowsAPI function returns a handle to the instance of the opened program. However, when I have discovered that no matter what program I start with it, ShellExecute returns 42. Even stranger is that it continues to return 42 no matter how many instances of the program I start. I have to use ShellExecute because I need to start a program using it's shortcut, something the Shell command doesn't do. Also, I need the handle of the program started so I can shut it down later. Anyone have any ideas?

MartinLiss
Nov 9th, 1999, 10:07 PM
See the answer I just posted http://www.vb-world.net/ubb/Forum1/HTML/010223.html for a working example of ShellExecute.

------------------
Marty

barrie
Nov 9th, 1999, 10:17 PM
I'm afraid that doesn't help, as it still doesn't tell me why ShellExecute is return 42 rather than the handle of the instance of the program it is starting. The function is working, in that it is starting the desired program. However, it always returns 42, no matter how many instances I start with it. 42 cannot be the handle to every instance.

Frans C
Nov 11th, 1999, 10:19 PM
As far as I know, ShellExecute doesn't return a handle to the opened process. It returns a number greater then 32 on success, 31 if no association exists, 0 if the system is out of memory or resources. ERROR_FILE_NOT_FOUND(2) if the file does not exist. ERROR_PATH_NOT_FOUND(3) if the path does not exist and ERROR_BAD_FORMAT(11) if the executable format is invalid. Possibly there are more of these, but these are the most common ones.