ShellExecute() & EnumWindows()?

This is a discussion on ShellExecute() & EnumWindows()? within the Windows Programming forums, part of the Platform Specific Boards category; hi, below i read a file path from a data file and open that file with ShellExecute(). then i read ...

  1. #1
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    386

    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?

    Code:
    .....
    savedat>>path; //file path
    ShellExecute(NULL,"open",path,NULL,NULL,SW_SHOWNORMAL);
    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);
      .......
      if(strstr(title,wndname)!=NULL)
      {
        //dostuff
        .......
      }
    }
    thanx.
    Last edited by geek@02; 09-19-2005 at 10:15 PM.
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature english)

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    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, 04:17 PM
  2. ShellExecute() string problem
    By henrikstolpe in forum Windows Programming
    Replies: 2
    Last Post: 05-21-2003, 10: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21