2 Replies - 575 Views - Last Post: 15 January 2013 - 11:51 AM Rate Topic: -----

#1 EB547  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 20-February 09

Command Line Parameter Through WinMain Problem

Posted 15 January 2013 - 05:33 AM

Hello All!
I've been playing around with OpenGL and the windows API, but came across a little problem. I've seen people talking about how to implement Argv-type functions into their WinMain method using CommandLineToArgvW(). I've attempted to do this, and use some clever code mechanics to adjust the height of the window based on the parameters, but for some reason, even though my code compiles, it ignores the flags and gives it the default window size. I've had no idea how to correct it as I'm new to the WindowsAPI.
Code:
LPWSTR *szArgList;
int argCount;

szArgList = CommandLineToArgvW(GetCommandLineW(), &argCount);

for(int i = 1;i < argCount;i++)
{
    if(i + 1 != argCount)
    {
        if(szArgList[i] == L"-w")
        {
            width = _wtoi(szArgList[i+1]);
        }
        else if(szArgList[i] == L"-h")
        {
            height = _wtoi(szArgList[i+1]);
        }
    }
}
MSG msg;
BOOL done=FALSE;
if(MessageBox(NULL,"Fullscreen?", "my window", MB_YESNO|MB_ICONQUESTION)==IDNO)
{
    fullscreen=FALSE;
}
if(!CreateGLWindow("Window",width,height,16,fullscreen))
{
    return 0;
}



Thank You All!

Is This A Good Question/Topic? 0
  • +

Replies To: Command Line Parameter Through WinMain Problem

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3534
  • View blog
  • Posts: 10,943
  • Joined: 05-May 12

Re: Command Line Parameter Through WinMain Problem

Posted 15 January 2013 - 07:17 AM

You need to use strcmp() not equality checks to see if two strings are equal.
Was This Post Helpful? 1
  • +
  • -

#3 EB547  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 20-February 09

Re: Command Line Parameter Through WinMain Problem

Posted 15 January 2013 - 11:51 AM

Thank You!
Turns out a sister function, _wcsicmp() was what i was looking for. Works like a charm.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1