Discussion:
ShellExecute Open Folder and select file
(too old to reply)
Ajay Sonawane
2005-01-07 05:54:29 UTC
Permalink
Hi,
I'm looking for an API function that opens the windows
explorer on a specific folder and selecting a file in it.
I know that the function 'ShellExecute' can open windows
explorer but can it select a file (like after downloading
a file and pressing 'open folder' and the folder is
opened and the downloaded file is selected).
Thanks in advance.
David Lowndes
2005-01-07 10:36:24 UTC
Permalink
Post by Ajay Sonawane
I'm looking for an API function that opens the windows
explorer on a specific folder and selecting a file in it.
I know that the function 'ShellExecute' can open windows
explorer but can it select a file (like after downloading
a file and pressing 'open folder' and the folder is
opened and the downloaded file is selected).
Yes it can.

Use "Explorer" and "/select, c:\path\filename.ext" with ShellExecute
and it should work.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
a***@webtechdevelopers.com
2005-01-12 13:31:55 UTC
Permalink
Hello David
I tried using Explorer and "\select,pathofexe" , but ShellExecute
failed to open folder. Can u give me one working example ?
I tried like this


ShellExecute(NULL,"explorer","\select,m_szExePath",0,0,SW_MAXIMIZE);

Let me know it it is wrong.
Post by David Lowndes
Post by Ajay Sonawane
I'm looking for an API function that opens the windows
explorer on a specific folder and selecting a file in it.
I know that the function 'ShellExecute' can open windows
explorer but can it select a file (like after downloading
a file and pressing 'open folder' and the folder is
opened and the downloaded file is selected).
Yes it can.
Use "Explorer" and "/select, c:\path\filename.ext" with ShellExecute
and it should work.
Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
David Lowndes
2005-01-12 14:13:41 UTC
Permalink
Post by a***@webtechdevelopers.com
I tried using Explorer and "\select,pathofexe" , but ShellExecute
failed to open folder. Can u give me one working example ?
I tried like this
ShellExecute(NULL,"explorer","\select,m_szExePath",0,0,SW_MAXIMIZE);
Let me know it it is wrong.
Presumably m_szExePath is a variable in your program not part of a
string constant that you have there?

You need to construct a string containing your path, so something like
this will be needed:

CString strSel;
strSel = "/select, "; // I think the space may be needed!
strSel += m_szExePath;

ShellExecute(NULL,"explorer", strSel, 0,0,SW_MAXIMIZE);

Dave

Loading...