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?^^)
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, ...? :confused:
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?
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.
Re: Get the folders opened in explorer.exe
My Windows Explorer mainframe window has the "ExploreWClass" class name. :cool:
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, ...? :confused:
mainframe
Quote:
Which OS are you using? I couldn't find such a window class in Windows Explorer app in my WinXP SP2.
winXP SP3
Quote:
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 :confused: even in same OS?
BTW i saw this feature in some other prog and thought it was possible to replicate it.
Any furter idea?
Re: Get the folders opened in explorer.exe
Quote:
Originally Posted by Enrorr
mainframe
winXP SP3
...
So it seems that the classes are different :confused: 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. :cool:
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:
Quote:
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
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? :rolleyes:
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? :rolleyes:
Obviously no^^
After the Vista check we'll know a bit more
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.
Re: Get the folders opened in explorer.exe
Quote:
Originally Posted by Enrorr
In AUTOit forums i found:
Quote:
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!
Re: Get the folders opened in explorer.exe
Checked in VISTA:
The mainframe seems to be CabinetWClass.
So I can go on?^^
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();
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 ;)
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 ?