Thread: ShellExecute() & EnumWindows()?

  1. #1
    Android geek@02's Avatar
    Join Date
    Mar 2004
    Kurunegala Colony, Sri Lanka, Sri Lanka

    ShellExecute() & EnumWindows()?

    hi, below i read a file path from a data file and open that file with ShellExecute(). then i read the window name of that file from the data file(it's been stored previously), and search for that window with EnumWindows(), cos i want a handle to it. But in the window list i cannot see the name of the window i've just opened with ShellExecute(). why is that please?

    savedat>>path; //file path
    savedat.getline(wndname,256,'$'); // wnd name
    EnumWindows(Wndfunc1, NULL); // srch 4 wnd name
    BOOL CALLBACK Wndfunc1(HWND hwnd, LPARAM lParam )
      char title[256];
      GetWindowText(hwnd, title, 256);
    Last edited by geek@02; 09-19-2005 at 09:15 PM.
    My amature IT Blog:
    My Flash games:

    (and, sorry for my amateur English)

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    You need to give the process some time to create its window. The best approach would be to call ShellExecuteEx and then use WaitForInputIdle with the returned hProcess. Alternatively, you could just add a Sleep after calling ShellExecute. Of course, for some programs the pause you choose may not be long enough. Also, you can use FindWindow instead of searching for the window manually.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ShellExecute Problem
    By dhrodrigues in forum Windows Programming
    Replies: 2
    Last Post: 04-12-2004, 03:17 PM
  2. ShellExecute() string problem
    By henrikstolpe in forum Windows Programming
    Replies: 2
    Last Post: 05-21-2003, 09:54 AM
  3. EnumWindows + XP
    By FillYourBrain in forum Windows Programming
    Replies: 9
    Last Post: 02-16-2003, 08:44 PM
  4. ShellExecute and popups or MessageSending
    By Unregistered in forum Windows Programming
    Replies: 0
    Last Post: 01-03-2002, 09:50 AM