0

For example i have a program thats "main" function is defined as wmain.

int wmain( int argc, wchar_t *argv[] ) {
    wchar_t* lpModulePath = NULL;
    wchar_t* lpFunctionName = NULL;
    lpModulePath = argv[1];
    lpFunctionName = argv[2];
}

and of course uses wchar_t types. How can i write a function

int main( int argc, char *argv[] )

that converts the parameters passed as char to wchar_t and then calls wmain by itself?

Thank you

hellow
  • 12,430
  • 7
  • 56
  • 79
Jane dOE
  • 21
  • 6

1 Answers1

0

On Windows you can use GetCommandLineW() and CommandLineToArgvW():

int main(int argc, char* argv[])
{
    wchar_t** wargv = CommandLineToArgvW(GetCommandLineW(), &argc);
    int ret = wmain(argc, wargv);
    LocalFree(wargv);
    return ret;
}

On Linux I'm afraid you'd have to allocate the array and convert strings in loop.

Avert
  • 435
  • 3
  • 17