Board index » cppbuilder » how to select a file in Explorer?

how to select a file in Explorer?


2006-07-26 12:16:06 AM
cppbuilder20
Hello, everybody!
Does anybody know how to programmatically launch Windows Explorer and then
select an existing file in its list view pane?
The following code:
ShellExecute(<hwnd>, "explore", <folder>, NULL, "", SW_SHOWNORMAL);
does half the task - it launches Explorer and opens the specified <folder>.
But how to make Explorer select some file in this folder?
Any help will be appreciated.
Thank you.
Edward.
 
 

Re:how to select a file in Explorer?

"Edward" < XXXX@XXXXX.COM >wrote
Quote
Does anybody know how to programmatically launch Windows Explorer and then
select an existing file in its list view pane?

The following code:

ShellExecute(<hwnd>, "explore", <folder>, NULL, "", SW_SHOWNORMAL);

you can use the following
ShellExecute(Handle,"","explorer","/select,C:\\FullPathHere\\YourFile.Ext",NULL,SW_SHOWNORMAL);
_minas
------
"Only the virtue's conquests have certainty" Sofokleous Erephyle
 

Re:how to select a file in Explorer?

Thank you, Minas,
It's so simple...
I tried it under XP and this works. But will it work under 98 and Me?
"Minas" <(min_charATyahooPUTADOTgr)(HellenicFire)>wrote in message
Quote

"Edward" < XXXX@XXXXX.COM >wrote

>Does anybody know how to programmatically launch Windows Explorer and
>then select an existing file in its list view pane?
>
>The following code:
>
>ShellExecute(<hwnd>, "explore", <folder>, NULL, "", SW_SHOWNORMAL);
>

you can use the following


ShellExecute(Handle,"","explorer","/select,C:\\FullPathHere\\YourFile.Ext",NULL,SW_SHOWNORMAL);


_minas
------
"Only the virtue's conquests have certainty" Sofokleous Erephyle

 

{smallsort}

Re:how to select a file in Explorer?

"Edward" < XXXX@XXXXX.COM >έγραψε στ?μήνυμα
Quote
I tried it under XP and this works. But will it work under 98 and Me?
the folllowing works in winxp and win98
ShellExecute(NULL,"open","explorer","
/select,C:\\FullPathHere\\YourFile.Ext","",SW_SHOWNORMAL);
The only *problem* in WIN98 I got is that if you include the /e switch the
file is not
highlighted but the selection remains on the folder in the left pane.
What I mean for /e switch
ShellExecute(NULL,"open","explorer","
/e,/select,C:\\FullPathHere\\YourFile.Ext","",SW_SHOWNORMAL);
in WINXP shows also folders pane with file selected and current folder
grayed but in WIN98 the
selection appears only on the folder
So better don't use /e (show folders pane) switch if you plan it
for older systems.
_minas
------
"Only the virtue's conquests have certainty" Sofokleous Erephyle
 

Re:how to select a file in Explorer?

Thank you Minas,
It really helped me.
Edward.
"Minas" <(min_charATyahooPUTADOTgr)(HellenicFire)>wrote in message
Quote
"Edward" < XXXX@XXXXX.COM >έγραψε στ?μήνυμα
news: XXXX@XXXXX.COM ...

>I tried it under XP and this works. But will it work under 98 and Me?

the folllowing works in winxp and win98

ShellExecute(NULL,"open","explorer","
/select,C:\\FullPathHere\\YourFile.Ext","",SW_SHOWNORMAL);

The only *problem* in WIN98 I got is that if you include the /e switch the
file is not
highlighted but the selection remains on the folder in the left pane.

What I mean for /e switch

ShellExecute(NULL,"open","explorer","
/e,/select,C:\\FullPathHere\\YourFile.Ext","",SW_SHOWNORMAL);

in WINXP shows also folders pane with file selected and current folder
grayed but in WIN98 the
selection appears only on the folder
So better don't use /e (show folders pane) switch if you plan it
for older systems.

_minas
------
"Only the virtue's conquests have certainty" Sofokleous Erephyle