Reputation: 671
I am writing a small C++ program which gets as input from the program command line, a string to later be passed to another function.
The problem is that this function expects to get a LPWSTR (wchar_t*
) type variable, and the regular char** argv
is an array of elements from the type of char*
.
Is there any way to get the argv variable as a LPWSTR*
type?
Thanks
Upvotes: 1
Views: 824
Reputation: 671
A simple solution can be acheived by combining both GetCommandLineW()
and CommandLineToArgvW()
in the following way:
int main() {
int argc = 0;
LPWSTR* pArgvW = CommandLineToArgvW(GetCommandLineW(), &argc);
// use pArgvW as needed...
LocalFree(pArgvW);
...
return 0;
}
Reading GetCommandLineW and CommandLineToArgvW documentation might also help.
Upvotes: 3