Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: IHNIWTFID on September 17, 2012, 12:08:58 pm

Title: Problem with CommandLineToArgvW
Post by: IHNIWTFID on September 17, 2012, 12:08:58 pm
Hi, I'm trying to get the arguments from commandline inside WinMain.
Im using this code:
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?
Title: Re: Problem with CommandLineToArgvW
Post by: jarod42 on September 17, 2012, 12:44:22 pm
Unrelated to Code::Blocks.
but I assume you use g++ in Code::Blocks

LPWSTR != LPSTR and your conversion is not portable.
Title: Re: Problem with CommandLineToArgvW
Post by: Jenna on September 17, 2012, 01:06:13 pm
Unrelated to Code::Blocks.

and therefore violating our forum rules !

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

Topic locked !