Thread: ShellExecuteEx

  1. #1
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    ShellExecuteEx

    I have this oddity when calling ShellExecuteEx with SEE_MASK_NOCLOSEPROCESS in the fMask member. The function returns TRUE as in success but the hProcess member is still NULL. How can this be? If no process remains shouldn't the function return FALSE?

    EDIT: nm, for some reason this error disappeared. Must've been a recompilation or something...
    Last edited by Magos; 03-01-2006 at 10:05 AM.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Use to indicate that the hProcess member receives the process handle. This handle is typically used to allow an application to find out when a process created with ShellExecuteEx terminates. In some cases, such as when execution is satisfied through a DDE conversation, no handle will be returned. The calling application is responsible for closing the handle when it is no longer needed.
    Often, you'll get a process handle only if there is no instance of the program open when you make the call.

  3. #3
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Magos, I noticed that you asked a question about a browser through your program, and that
    someone answered with ShellExecuteEx() and SEE_MASK_NOCLOSEPROCESS. And now
    you are asking a question about ShellExecuteEx() and SEE_MASK_NOCLOSEPROCESS,
    meaning you have some script to have a browser in your program? If so, could you share the code
    you have with me? The reason I am asking is because I have tried to use ShellExecuteEx() before,
    and I couldn't get it to work, so if I got some working code, it would help me.

    Thanks, August.

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    I have no browser, that was another guy.
    Launching a new process aint that hard though:
    Code:
    SHELLEXECUTEINFO Info;
    std::string FileName;
    
    FileName = "C:\\MyFile.txt";
    
    ZeroMemory(&Info, sizeof(SHELLEXECUTEINFO));
    Info.cbSize = sizeof(SHELLEXECUTEINFO);
    Info.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
    Info.lpFile = FileName.c_str();
    Info.hInstApp = GetModuleHandle(NULL);
    Info.nShow = SW_SHOW;
    
    if(!ShellExecuteEx(&Info)) return FALSE;
    
    //The created process is in:
    Info.hProcess;
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. mixed success with ShellExecuteEx
    By Gerread in forum Windows Programming
    Replies: 3
    Last Post: 11-27-2007, 03:52 AM