|
Had it been anything other than explorer.exe, the answer would have only been five minutes away. However, explorer.exe is different in that it doesn't, by default, start a new application each time. It gets its own thread but within an already existing process. To work around this, a registry change was required. Create the following DWORD key:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer]
"DesktopProcess"=dword:00000001
This code will now open Windows Explorer in 'filmstrip' view:
HWND _hWnd = NULL;
BOOL CALLBACK EnumProc( HWND hWnd, LPARAM lParam )
{
DWORD dwProcessId;
GetWindowThreadProcessId(hWnd, &dwProcessId);
if ((DWORD) lParam == dwProcessId)
{
char szText[256];
if (::GetWindowText(hWnd, szText, sizeof(szText)) > 0)
{
char szClass[256];
GetClassName(hWnd, szClass, sizeof(szClass));
if (lstrcmp(szClass, "CabinetWClass") == 0)
{
_hWnd = hWnd;
return FALSE;
}
}
}
return TRUE;
}
...
DWORD dwError;
BOOL bResult;
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
si.cb = sizeof(si);
bResult = CreateProcess(NULL,
"c:\\windows\\explorer.exe \"C:\\Documents and Settings\\<user>\\My Documents\\My Pictures\\<folder>\"",
NULL,
NULL,
TRUE,
NORMAL_PRIORITY_CLASS,
NULL,
NULL,
&si,
&pi);
if (! bResult)
dwError = GetLastError();
WaitForInputIdle(pi.hProcess, 3000);
EnumWindows(EnumProc, pi.dwProcessId);
HWND hWnd = FindWindowEx(_hWnd, NULL, "SHELLDLL_DefView", "");
if (hWnd != NULL)
::SendMessage(hWnd, WM_COMMAND, 0x702f, 0); Obviously this solution has a few shortcomings but I think you get the general idea. I think that FindWindow() can also be used to find the "CabinetWClass" window.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I just posted an article about automating Internet Explorer and Explorer on Codeproject (http://www.codeproject.com/shell/AutomateShellWindow.asp).
To switch to 'Film Strip' mode, use IFolderView::SetCurrentViewMode with FVM_THUMBSTRIP. IFolderView can be QIed from the active shell view in explorer.
My blogs:
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
Hi JIANG,
thanks for the reply...
i've looked eariler at your code posted here...tried to simulate it but didn't get much luck..
can you copy and paste bits of your code here to answer my quiz
all i need to do is open explorer in a certain directory and then switch it to film strip view
an easiest approach for me would be to write something like this:
using shellexecute , "explorer.exe /n,c:\.....\MyFolder"
and then set a registry key that customize this folder to 'filmstrip'
i've been shown by DavidCrow where the windows store this customization, all i have to look for now is how the system find the folder according to the number in the registy...
can u help there?
thanks again
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
YaronNir wrote: and then set a registry key that customize this folder to 'filmstrip'
Look at the Vid and Mode values.
Details:
"Vid"="{137E7700-3573-11CF-AE69-08002B2E1262}"
"Mode"=dword:00000004
Icons:
"Vid"="{0057D0E0-3573-11CF-AE69-08002B2E1262}"
"Mode"=dword:00000001
List:
"Vid"="{0E1FA5E0-3573-11CF-AE69-08002B2E1262}"
"Mode"=dword:00000003
Thumbnails:
"Vid"="{8BEBB290-52D0-11D0-B7F4-00C04FD706EC}"
"Mode"=dword:00000005
Tiles:
"Vid"="{65F125E5-7BE1-4810-BA9D-D271C8432CE3}"
"Mode"=dword:00000006
Filmstrip:
"Vid"="{8EEFA624-D1E9-445B-94B7-74FBCE2EA11A}"
"Mode"=dword:00000007
YaronNir wrote: i've been shown by DavidCrow where the windows store this customization, all i have to look for now is how the system find the folder according to the number in the registy...
After looking at the HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\BagMRU key and its subkeys, I can only guess it's some sort of hashing algorithm.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
well, you're correct, the FilmStrip is indeed 8EEFA624-D1E9-445B-94B7-74FBCE2EA11A
but i still can't figure it out what is the connection between the number and the refered directory ?
i think an easier solution to my entire problem would be just call shell execute with
"explorer.exe /n,"c:\.....\my folder"
and then set a registry key (the right one - that fits to this folder) with the filmstrip mode
(i.e. Filmstrip:"Vid"="{8EEFA624-D1E9-445B-94B7-74FBCE2EA11A}""Mode"=dword:00000007 )
help????
thanks again
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
<code>
//my sample code from http://www.codeproject.com/shell/AutomateShellWindow.asp
CComQIPtr<IServiceProvider> psp(m_pWebBrowser2);
CComPtr<IShellBrowser> psb;
CComPtr<IShellView> psv;
if(psp)
psp->QueryService(SID_STopLevelBrowser,
IID_IShellBrowser,(LPVOID*)&psb);
if(psb)
psb->QueryActiveShellView(&psv);
if(psv)
{
//new code here
CComPtr<IFolderView> pfv(psv);
if(pfv) pfv->SetCurrentViewMode(FVM_THUMBSTRIP);
//end new code
</code>
My blogs:
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
-- modified at 14:11 Tuesday 15th November, 2005
|
|
|
|
|
thanks for the reply
the above code doesn't compile due to
CComPtr<IFolderView> pfv(psv);
i use VC7 DOTNET 2003....
any suggestion?
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
CComPtr<ifolderview> pfv(psv);
I'v modified my post and removed HTML formating.
My blogs:
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
I've used a similar code taken from a page here at code project....
this code doesn't work because when i create new explorer.exe process (and since the registry new entry tells the explorer to be opened in a new process), i see an other explorer.exe in memory,
the enumproc does find it but the class name of the new explorer process is 'Desktop Proxy' (that is what GetClassName returns) only after the window is being show the spy++ tells that the class name is 'CabinetWClass'....
dunno why system works that way....
any thoughts?
really appreciate all your help!
cheers
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
YaronNir wrote: I've used a similar code taken from a page here at code project....
Which article are you referring to?
YaronNir wrote: this code doesn't work...
That's too bad as it worked fine for me.
YaronNir wrote: any thoughts?
Are you giving the new window enough time to be created before calling EnumWindows() ?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Which article are you referring to?
http://www.codeproject.com/shell/AutomateShellWindow.asp (it was one of the replies to this thread)
DavidCrow wrote: That's too bad as it worked fine for me.
how come? which system? xp? with sp? 1 ? 2?
DavidCrow wrote: Are you giving the new window enough time to be created before calling EnumWindows()?
tried to give it 3 to 5 seconds interval.....i use WaitForInputIdeal...
any thoughts?
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
YaronNir wrote: which system? xp? with sp? 1 ? 2?
Windows XP with SP2.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Finally i've solved the problem
it appeared to be that if i launch web browser (using IWebBrowser2) and set it to my desire
folder, it presents the folder automatically in FilmStrip mode....
so all i had to do is this:
CString szFilesDir(_T("c:\\windows\\system32\\MyDir"));
CComVariant vaURL( ( LPCTSTR) szFilesDir);
CComVariant vtEmpty;
IWebBrowser2Ptr spWB = NULL;
HRESULT hr = spWB.CreateInstance(CLSID_InternetExplorer);
hr = spWB->put_StatusBar(VARIANT_TRUE);
hr = spWB->put_ToolBar(VARIANT_TRUE);
hr = spWB->put_MenuBar(VARIANT_TRUE);
hr = spWB->put_Visible(VARIANT_TRUE);
hr = spWB->Navigate2(&vaURL,&vtEmpty,&vtEmpty,&vtEmpty,&vtEmpty);
thank you very much both of you, for all your help!!!
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
hi
I made a program using VS 2003. This program keep a thread running all the time. When the screensaver start the program show a error message. If I ignory the error the program keep running without problem.
I want to know why that error occur?
=^_______^=
[www.bispenho.com]
|
|
|
|
|
bispenho wrote: This program keep a thread running all the time. When the screensaver start the program show a error message. If I ignory the error the program keep running without problem.
could you tell me the exact error message string.. ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Sorry but the error has occured when the machine get stand-by mode. The message is: Debug Assertion Failed.
I thought weird the fact that I was running a programm just using the exe file but the error message showed me the line and the file name source where the error has occured.
I don't have experience in development using C++ so my other doubt is how the VC can show the .cpp file and line with error when I'm running the program out of VS?
=^_______^=
[www.bispenho.com]
|
|
|
|
|
I can't remember details, but you probably built the EXE in DEBUG mode, not RELEASE mode. DEBUG mode EXE files include debug information like file name and line numbers, etc.
Debug / Release selection is in Project settings, I think (I don't have VS on my office PC.)
|
|
|
|
|
hnn it's true. Thanks a lot =)
|
|
|
|
|
bispenho wrote: Debug Assertion Failed.
What line of what file asserted? That will give you a big clue as to why the program crashed.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hi everybody. Do you think it's possible to send a BSTR to VC++ via WM_COPYDATA? I just tried it using a VB Application. VB uses BSTRs and I set up a structure to send which also contains 2 string members. However, when I receive that in VC++, explorer.exe crashes (since the VC++ is actually a DLL hooking explorer.exe). The structure in VB is something like this:
Public Type SomeStructure<br />
zz As String<br />
xx As Long<br />
yy As Long<br />
ss As String<br />
End Type
Translated to VC++ it looks like this:
<br />
struct CustomStructure<br />
{<br />
BSTR sOne;<br />
long lTwo;<br />
long lThree;<br />
BSTR sFour;<br />
};
However, in VB the size of that structure is reported as 16 by the LenB function.
So do you think it's more like a process boundary issue, or simply a mistake in my approach?
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
Hello.
If you suspect that the crash is caused by diffrent struct sizes, then pack the VC struct, like this:
<code>
#pragma pack(1)
struct CustomStructure
{
BSTR sOne;
long lTwo;
long lThree;
BSTR sFour;
};
#pragma pack()
</code>
Then your VC struct will be 16 too.
|
|
|
|
|
WM_COPYDATA will only copy the root data in the buffer. Thus things such as pointers to other objects will only have the pointers and not the objects copied. In your case, the BSTR pointers will be copied but the strings the point to will not be.
All the data must be serialized into a single buffer containing no pointers to other data.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi CPians,
Using SHBrowseForFolder, how do I start browsing from a given directory and not from the desktop ?
The pidlRoot parameter of the function seems to be the key, however I do not have the slightest idea how to deal with it. I have one MSDN example where the init directory is set to the current directory, but it uses callbacks and seems to me as using a blockbuster to catch a fly.
Any idea ?
~RaGE();
|
|
|
|
|
|