From: hellokareem on
I am facing one small issue in ShellExecute Open Folder and select
file.
code here
CString file=L"/select,";
file= file + _mFilePath
ShellExecute(NULL,L"open",L"explorer",file,NULL,SW_SHOWNORMAL);

working fine, but in Windows XP , if folder already opened , not
selecting that specified file.
this is working fine in 2007 .Am I missing somthing or known issue?


From: Mikel on
On 26 abr, 16:22, hellokareem <kareem...(a)gmail.com> wrote:
> I am facing one small issue in  ShellExecute Open Folder and select
> file.
> code here
> CString file=L"/select,";
>         file= file + _mFilePath
>    ShellExecute(NULL,L"open",L"explorer",file,NULL,SW_SHOWNORMAL);
>
> working fine, but in Windows XP , if  folder already opened , not
> selecting that  specified file.
> this is working fine in 2007 .Am I missing somthing or known issue?

I found the same behavior just the other day, and I reached the
conclusion (I might be wrong) that it just works that way.

However, I would like to point out one thing about your code: if you
are using CString and ShellExecute, and not CStringW and
ShellExecuteW, you should type _T("open") and not L"open". Otherwise,
you are passing Unicode strings to generic-text functions, which is
working now because you have defined UNICODE and _UNICODE, but is not
right, and can lead to problems.
From: Giovanni Dicanio on
"Mikel" <mikel.luri(a)gmail.com> wrote:

>> CString file=L"/select,";
>> file= file + _mFilePath
>> ShellExecute(NULL,L"open",L"explorer",file,NULL,SW_SHOWNORMAL);
[...]
> However, I would like to point out one thing about your code: if you
> are using CString and ShellExecute, and not CStringW and
> ShellExecuteW, you should type _T("open") and not L"open". Otherwise,
> you are passing Unicode strings to generic-text functions, which is
> working now because you have defined UNICODE and _UNICODE, but is not
> right, and can lead to problems.

I think in these days is just fine to use Unicode-only string literals (i.e.
those with L"..." decoration) instead of generic text (i.e. _T("...")),
without specifying the 'W' suffix.
I mean, I think that:

ShellExecute(..., L"open", L"explorer", ...)

is just fine, and I don't like uglifying the code with ShellExecuteW...

I agree with what you wrote only if you have to maintain *both* ANSI and
Unicode builds.
(Note also that modern Win32 APIs tend to be Unicode only.)

My 2 cents,
Giovanni


From: Tom Serface on
I use the L"" version all the time now since I never want to go back to ANSI
and it is much easier to type. I wish there was a compile switch that just
assumed all strings were Unicode unless specified to be ANSI. I know... it
would break someone's program :o)

Tom

"Giovanni Dicanio" <giovanniDOTdicanio(a)REMOVEMEgmail.com> wrote in message
news:OoWrdKV5KHA.1888(a)TK2MSFTNGP05.phx.gbl...
> "Mikel" <mikel.luri(a)gmail.com> wrote:
>
>>> CString file=L"/select,";
>>> file= file + _mFilePath
>>> ShellExecute(NULL,L"open",L"explorer",file,NULL,SW_SHOWNORMAL);
> [...]
>> However, I would like to point out one thing about your code: if you
>> are using CString and ShellExecute, and not CStringW and
>> ShellExecuteW, you should type _T("open") and not L"open". Otherwise,
>> you are passing Unicode strings to generic-text functions, which is
>> working now because you have defined UNICODE and _UNICODE, but is not
>> right, and can lead to problems.
>
> I think in these days is just fine to use Unicode-only string literals
> (i.e. those with L"..." decoration) instead of generic text (i.e.
> _T("...")), without specifying the 'W' suffix.
> I mean, I think that:
>
> ShellExecute(..., L"open", L"explorer", ...)
>
> is just fine, and I don't like uglifying the code with ShellExecuteW...
>
> I agree with what you wrote only if you have to maintain *both* ANSI and
> Unicode builds.
> (Note also that modern Win32 APIs tend to be Unicode only.)
>
> My 2 cents,
> Giovanni
>
>
From: Tom Serface on
I've noticed this before and I think this is just how it works.

If you want to just select a file, you could use a CFileDialog (still and
Explorer, but more select file oriented). That does work for selected a
specific file, path, and or multiple file extension types.

Tom

"hellokareem" <kareem.tk(a)gmail.com> wrote in message
news:a1caa40c-6be5-4159-8b49-384f77d42760(a)s21g2000pri.googlegroups.com...
> I am facing one small issue in ShellExecute Open Folder and select
> file.
> code here
> CString file=L"/select,";
> file= file + _mFilePath
> ShellExecute(NULL,L"open",L"explorer",file,NULL,SW_SHOWNORMAL);
>
> working fine, but in Windows XP , if folder already opened , not
> selecting that specified file.
> this is working fine in 2007 .Am I missing somthing or known issue?
>
>