CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    Join Date
    Jun 2008
    Posts
    43

    Get the folders opened in explorer.exe

    Maybe this is a thousand already asked question but i can't find anything (even in big G).
    Anyway, my purpose is to get the paths opened of all the explorer.exe windows.

    If there isn't a simple way could you please give me some links about reading infos from other process?

    Since now I figured that the class of every explorer windows is CabinetWClass (am i wrong?) so using it with FindWindow could be a start (or not?^^)

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Get the folders opened in explorer.exe

    Quote Originally Posted by Enrorr
    Since now I figured that the class of every explorer windows is CabinetWClass (am i wrong?) so using it with FindWindow could be a start (or not?^^)
    Are you sure? Which window do you mean: mainframe, splitter, view, tool-/re-/statusbar, ...?
    Which OS are you using? I couldn't find such a window class in Windows Explorer app in my WinXP SP2.
    And I am not sure this class (if already exists in some version) will be used in the next versions and was used in all the previous ones.

    And BTW, are you going to consider all GetOpenFileName/GetSaveFileName dialogs too?
    Victor Nijegorodov

  3. #3
    Join Date
    Jul 2001
    Location
    Netherlands
    Posts
    751

    Re: Get the folders opened in explorer.exe

    I'm running XP service pack 2 and explorer windows have the CabinetWClass classname.
    So you could enumerate those windows, look for SysListView32 (or ComboBox) elements inside it and query those.
    Last edited by fransn; July 16th, 2008 at 04:24 AM.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Get the folders opened in explorer.exe

    My Windows Explorer mainframe window has the "ExploreWClass" class name.
    Victor Nijegorodov

  5. #5
    Join Date
    Jun 2008
    Posts
    43

    Re: Get the folders opened in explorer.exe

    Quote Originally Posted by VictorN
    Are you sure? Which window do you mean: mainframe, splitter, view, tool-/re-/statusbar, ...?
    mainframe

    Which OS are you using? I couldn't find such a window class in Windows Explorer app in my WinXP SP2.
    winXP SP3

    And BTW, are you going to consider all GetOpenFileName/GetSaveFileName dialogs too?
    No just the explorer mainframes

    So it seems that the classes are different even in same OS?

    BTW i saw this feature in some other prog and thought it was possible to replicate it.


    Any furter idea?
    Last edited by Enrorr; July 16th, 2008 at 05:21 AM.

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Get the folders opened in explorer.exe

    Quote Originally Posted by Enrorr
    mainframe


    winXP SP3
    ...
    So it seems that the classes are different even in same OS?
    Well, in my WinXP SP3 [Version 5.1 (Build 2600-xpsp.080413-2111 : Service Pack 3)] + Internet Explorer 7 (7.0.5730.13)
    windows explorer main window still has class name "ExploreWClass".
    So, please, conclude yourself.
    Victor Nijegorodov

  7. #7
    Join Date
    Jun 2008
    Posts
    43

    Re: Get the folders opened in explorer.exe

    In AUTOit forums i found:
    Code:
    If WinActive("classname=ExploreWClass") _
    Or WinActive("classname=CabinetWClass") Then
    ToolTip("Explorer Window is Active")
    And:
    CabinetWClass = right click on "my computer" and select open
    ExploreWClass = right click on "my computer" and select explore

    Make a folder on the desktop.
    Double click = CabinetWClass
    Make the folders show like a classic two pane view and it is still a CabinetWClass
    so it seems that both classname are used in WinXP...
    In a little i'm gonna test it in Vista and let you know

    PS:same build of XP as me
    Last edited by Enrorr; July 16th, 2008 at 05:24 AM.

  8. #8
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Get the folders opened in explorer.exe

    But are you sure there are no / won't ever be any other variants for class name?
    Victor Nijegorodov

  9. #9
    Join Date
    Jun 2008
    Posts
    43

    Talking Re: Get the folders opened in explorer.exe

    Quote Originally Posted by VictorN
    But are you sure there are no / won't ever be any other variants for class name?
    Obviously no^^
    After the Vista check we'll know a bit more

  10. #10
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Get the folders opened in explorer.exe

    What you could do is restrict the search to searching windows that are only in an Explorer.exe process. You can also help restrict the search by comparing other things like parent window (and it's class name) or perform a partial/complete class name match.

    See the EnumWindows code in this post for a sample.

  11. #11
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Get the folders opened in explorer.exe

    Quote Originally Posted by Enrorr
    In AUTOit forums i found:
    CabinetWClass = right click on "my computer" and select open
    ExploreWClass = right click on "my computer" and select explore

    Make a folder on the desktop.
    Double click = CabinetWClass
    Make the folders show like a classic two pane view and it is still a CabinetWClass
    Well, yes, when I open "My Computer" or "My Documents" I get "CabinetWClass", and when I open "Windows Explorer" - then 'ExploreWClass'.
    And after App has started, then it doesn't ,of course, change this class name anymore, whether it uses "classic two pane view" or only one view!
    Victor Nijegorodov

  12. #12
    Join Date
    Jun 2008
    Posts
    43

    Re: Get the folders opened in explorer.exe

    Checked in VISTA:
    The mainframe seems to be CabinetWClass.

    So I can go on?^^

  13. #13
    Join Date
    Nov 2007
    Posts
    613

    Re: Get the folders opened in explorer.exe

    If you're trying to allow the user to pick a folder, you're on a wrong path.

    Your technique can lead to many nasty surprises. The user may have lots of explorer windows opened on the desktop. He may close the explorer window you open for him.

    The right approach is to use the "Browse For Folders" dialog box. The feature is provided by the Shell.

    Try this code:
    Code:
    IMalloc __RPC_FAR* pMalloc;
    if(::SHGetMalloc(&pMalloc) == NOERROR)
    {
     char pszPath[MAX_PATH];
     BROWSEINFO bi;
     bi.hwndOwner = GetSafeHwnd();
     bi.pidlRoot = NULL;
     bi.pszDisplayName = pszPath;
     bi.lpszTitle = _T("Select a Folder");
     bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
     bi.lpfn = NULL;
     bi.lParam = 0;
     ITEMIDLIST* pIDL;
     if(pIDL = ::SHBrowseForFolder(&bi))
     {
      if(::SHGetPathFromIDList(pIDL, pszPath))
      {
       MessageBox(pszPath);
      }
     pMalloc->Free(pIDL);
     }
     pMalloc->Release();

  14. #14
    Join Date
    Jun 2008
    Posts
    43

    Re: Get the folders opened in explorer.exe

    Quote Originally Posted by srelu
    If you're trying to allow the user to pick a folder, you're on a wrong path.

    Your technique can lead to many nasty surprises. The user may have lots of explorer windows opened on the desktop. He may close the explorer window you open for him.

    The right approach is to use the "Browse For Folders" dialog box. The feature is provided by the Shell.

    Try this code:
    Code:
    IMalloc __RPC_FAR* pMalloc;
    if(::SHGetMalloc(&pMalloc) == NOERROR)
    {
     char pszPath[MAX_PATH];
     BROWSEINFO bi;
     bi.hwndOwner = GetSafeHwnd();
     bi.pidlRoot = NULL;
     bi.pszDisplayName = pszPath;
     bi.lpszTitle = _T("Select a Folder");
     bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
     bi.lpfn = NULL;
     bi.lParam = 0;
     ITEMIDLIST* pIDL;
     if(pIDL = ::SHBrowseForFolder(&bi))
     {
      if(::SHGetPathFromIDList(pIDL, pszPath))
      {
       MessageBox(pszPath);
      }
     pMalloc->Free(pIDL);
     }
     pMalloc->Release();
    I'm not doing this....
    And I'm not gonna open any new window, i just want to get the path from already opened ones.

    The user will have the possibility to choose if doing operation in an already open path (the one i'm stucking with) or to browse for another one with a dialog.

    I just want operations to be fastest as often the folder you're working it are already opened in explorer, if not you can still browse for them

  15. #15
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: Get the folders opened in explorer.exe

    What exactly are you trying to do ?
    Also, how exactly is using FindWindow etc.. going to help you ?

Page 1 of 2 12 LastLast

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