delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/12/09/10:36:55

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Thu, 9 Dec 2004 10:37:20 -0500
From: Christopher Faylor <cgf-no-personal-reply-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Incorrectly prepared lpCmdLine parameter of WinMain()
Message-ID: <20041209153720.GB11158@trixie.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
References: <41B839E2 DOT 5020803 AT mff DOT cuni DOT cz>
Mime-Version: 1.0
In-Reply-To: <41B839E2.5020803@mff.cuni.cz>
User-Agent: Mutt/1.4.1i

On Thu, Dec 09, 2004 at 12:41:22PM +0100, Pavel Kudrna wrote:
>The caller of WinMain() incorrectly parses the command line if e.g.
>the space is present in the path or filename of the executable.
>The lpCmdLine then contains part of the filename at the beginning.
>
>/* program.c*/
>#include <windows.h>
>int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, 
>LPSTR lpCmdLine, int nCmdShow )
>{
> MessageBox(NULL, lpCmdLine, "lpCmdLine:", MB_OK );
> return 0;
>}
>
>$ gcc program.c -mwin32
>$ mv a.exe "a a.exe"
>$ "./a a.exe" "1st parameter" 2nd\ parameter
>
>Then MessageBox shows that lpCmdLine contains:
>a.exe" "1st parameter" "2nd parameter"
>
>If program is compiled with -mno-cygwin the bug is not present and 
>lpCmdLine is ok:
>"1st parameter" "2nd parameter"

Sounds like you should be using argv[] rather than lpCmdLine.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019