CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2009
    Posts
    65

    Get the state of window opened by ShellExecute

    Hi all,
    I wanna know say I opened an exe using ShellExecute(), and now I wanna wait till its finished closing how can I do this.

    Code:
    //I can do upto here only
    HWND H;
    H=ShellExecute(MainWindow,"open","Dummy.exe",NULL,NULL,SW_SHOW);
    
    //After this i dnt know what to do
    
    [Test if H has closed] ???
    Thanks,
    Nisheeth

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    894

    Re: Get the state of window opened by ShellExecute

    You need to use ShellExecuteEx(), check here:
    http://msdn.microsoft.com/en-us/libr...54(VS.85).aspx

    after it returns TRUE, you need to wait for the SHELLEXECUTEINFO.hProcess before you close it:
    Code:
    if(lpExecInfo.hProcess)
    {
        WaitForSingleObject(lpExecInfo.hProcess, INFINITE);
        CloseHandle(lpExecInfo.hProcess);
    }
    Keep in mind though, that unlike CreateProcess() the ShellExecuteEx() does not always return a process handle.

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

Featured