|
-
July 16th, 2008, 03:21 AM
#1
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?^^)
-
July 16th, 2008, 03:43 AM
#2
Re: Get the folders opened in explorer.exe
 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
-
July 16th, 2008, 04:20 AM
#3
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.
-
July 16th, 2008, 04:27 AM
#4
Re: Get the folders opened in explorer.exe
My Windows Explorer mainframe window has the "ExploreWClass" class name.
Victor Nijegorodov
-
July 16th, 2008, 04:52 AM
#5
Re: Get the folders opened in explorer.exe
 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.
-
July 16th, 2008, 05:18 AM
#6
Re: Get the folders opened in explorer.exe
 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
-
July 16th, 2008, 05:21 AM
#7
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.
-
July 16th, 2008, 05:25 AM
#8
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
-
July 16th, 2008, 05:28 AM
#9
Re: Get the folders opened in explorer.exe
 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
-
July 16th, 2008, 05:48 AM
#10
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.
-
July 16th, 2008, 05:49 AM
#11
Re: Get the folders opened in explorer.exe
 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
-
July 16th, 2008, 07:02 AM
#12
Re: Get the folders opened in explorer.exe
Checked in VISTA:
The mainframe seems to be CabinetWClass.
So I can go on?^^
-
July 16th, 2008, 07:23 AM
#13
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();
-
July 16th, 2008, 01:05 PM
#14
Re: Get the folders opened in explorer.exe
 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
-
July 16th, 2008, 01:09 PM
#15
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 ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|