Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WinMain command line arguments

Tags:

winapi

The 3rd param to WinMain provides the command line as an unprocessed string. While that may be useful for allowing you to cope with expansion of wildcards and what-not, is there any chance that lurking somewhere in the Win32 API that there's a way to get the usual C argc, argv version of it?

like image 417
JustJeff Avatar asked Jun 01 '09 20:06

JustJeff


People also ask

What is WinMain in C?

WinMain is the conventional name used for the application entry point.

What is int WINAPI?

WINAPI is a macro that evaluates to __stdcall , a Microsoft-specific keyword that specifies a calling convention where the callee cleans the stack. The function's caller and callee need to agree on a calling convention to avoid corrupting the stack.


2 Answers

You can use CommandLineToArgvW() to convert to an argv-style array of Unicode strings. Unfortunately, there is no ANSI-string version. Also, beware that this does not set argv[argc] (i.e. the element after the last argument) to NULL.

like image 23
Adam Rosenfield Avatar answered Sep 25 '22 09:09

Adam Rosenfield


microsoft speciffic:

__argc and __argv

like image 178
newman911 Avatar answered Sep 23 '22 09:09

newman911