Author Topic: Problem with CommandLineToArgvW  (Read 5195 times)

Offline IHNIWTFID

  • Single posting newcomer
  • *
  • Posts: 2
Problem with CommandLineToArgvW
« 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?

Offline jarod42

  • Multiple posting newcomer
  • *
  • Posts: 87
Re: Problem with CommandLineToArgvW
« Reply #1 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.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Problem with CommandLineToArgvW
« Reply #2 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 !