Explore with ShellExecute and giving "focus" to a specific file in the "files" pane

Mutley2003
Mutley2003 used Ask the Experts™
on
hi
I can open a folder in Explorer with ShellExecute like so

ShellExecute(Application.Mainform.Handle,
                    pchar('explore'),
                    pchar('C:\Documents and Settings\Fred\My Documents')
but what I would really like to do is give "focus" to a specific FILE in the right hand files listing eg

ShellExecute(Application.Mainform.Handle,
                    pchar('explore'),
                    pchar('C:\Documents and Settings\Fred\My Documents\SomeBitmap.bmp')
which of course ShellExecute won't do. I looked at ShellExecuteEx and I can get to the properties page for a  noinated file, but that is not what I want.

Any idea how I can do this?

thanks

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2007

Commented:
Have you tried
WinExec(pchar('explorer /e, /select, C:\Documents and Settings\Fred\My Documents\SomeBitmap.bmp '), SW_SHOW);
Top Expert 2007
Commented:
or

ShellExecute(Handle,PChar('open'), PChar('explorer.exe'), PChar('/e, /select, C:\Documents and Settings\Fred\My Documents\SomeBitmap.bmp'), nil, SW_SHOW);

Author

Commented:
thanks, works fine.. I did not think of the command line switches on Explorer (see here http://support.microsoft.com/kb/130510) .

Initially I had a lot of trouble with the debugger window popping up (D5) .. eventually I tracked it down to the option "debug spawned processes" under "debugger options" which I had checked.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial