Results 1 to 4 of 4

Thread: ShellExecute Equals the Meaning of Life

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 1999
    Location
    Pierre, SD USA
    Posts
    23

    Post

    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?

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    See the answer I just posted http://www.vb-world.net/ubb/Forum1/HTML/010223.html for a working example of ShellExecute.

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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 1999
    Location
    Pierre, SD USA
    Posts
    23

    Post

    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.

  4. #4
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Post

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width