News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Problem with CommandLineToArgvW

Started by IHNIWTFID, September 17, 2012, 12:08:58 PM

Previous topic - Next topic

IHNIWTFID

Hi, I'm trying to get the arguments from commandline inside WinMain.
Im using this code:

LPWSTR *Arglist;
int nArgs;
Arglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
for(int i=0; i<nArgs; i++) cout<<(LPSTR)Arglist[i]<<endl;
LocalFree(Arglist);

The code above work fine in VS2010. But in Code::Blocks it returns only the first character of each argument.
Would someone please tell me what I'm doing wrong?

jarod42

Unrelated to Code::Blocks.
but I assume you use g++ in Code::Blocks

LPWSTR != LPSTR and your conversion is not portable.

Jenna

Quote from: jarod42 on September 17, 2012, 12:44:22 PM
Unrelated to Code::Blocks.

and therefore violating our forum rules !

Please respect the rules as you have accepted with registering here !

Topic locked !