Platform SDK Shell >> Bug in CommandLineToArgvW

by dXNmaW5lY2F0cw » Sat, 02 Apr 2005 09:35:01 GMT

Platform sdk: dlls, Process, and Threads says:

LPWSTR* CommandLineToArgvW(
LPCWSTR lpCmdLine,
int* pNumArgs
);



lpCmdLine
[in] Pointer to a null-terminated Unicode command-line string. An
application will usually directly pass on the value returned by a call to the
GetCommandLineW function.
If this parameter is the empty string, "", the function returns the path to
the current executable file

With a command line that looks like

C:\Program Files\MyCompany\MyApp

when I call CommandLineToArgvW(L"",&NumArgs);


this routine is returning "C:\Program" as argv[0]
and "Files\MyCompany\MyApp" as argv[1]
and telling me I've got 2 arguments.

This is not correct!


--
Gak -
Finecats


Platform SDK Shell >> RE: Bug in CommandLineToArgvW

by v-garych » Sat, 02 Apr 2005 14:02:48 GMT


Hi Gak,


Based on my understanding, it seems that you think the path of the current
EXE should be returned as a whole string, instead of parsed as several
arguments, please let me know if I have misunderstood it.

AFAIK, such behavior is as expected: since the CommandLineToArgvW function
has already returned the path of the current executable file due to the
empty lpCmdLine parameter, meanwhile, it will also take the return value as
the arguments to the current executable file.(however the Platform SDK does
not figure it out explicitly.)

So in this scenario, for the reason that the arguments to an application is
separated by space character, the return value(current EXE's path) would
be also parsed as a space separated argument list, which divides the return
EXE's path into an array of Unicode strings.

I hope the above clarification helps, if you have any questions or
concerns, please do not hesitate to let me know. I am standing by to help
you.


Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.




Platform SDK Shell >> RE: Bug in CommandLineToArgvW

by dXNmaW5lY2F0cw » Tue, 05 Apr 2005 12:51:06 GMT

Gary, the doc's say "the function returns the path to
the current executable file". It does not equivicate about spaces in the
name or other qualifications. Fix the doc's, fix the code, one or the other.
Larry.





RE: Bug in CommandLineToArgvW

by v-garych » Tue, 05 Apr 2005 16:53:25 GMT

>the doc's say "the function returns the path to the

OK Larry, there is some vagueness here in the documentation, I will contact
our correlated product team to review it in detail. We really appreciate
you taking the time to provide us this feedback.

If you have any other concerns, please feel free to let me know. It's my
pleasure to be of assistance.



Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.