Article View: borland.public.cppbuilder.nativeapi
Article #16112Re: CreateProcess() passing cmd line args
From: Remy Lebeau (TeamB)
Date: Fri, 30 May 2003 22:26
Date: Fri, 30 May 2003 22:26
39 lines
2526 bytes
2526 bytes
"CC" <Xcurtc@tmscorp.com> wrote in message
news:3ed7bb90@newsgroups.borland.com...
> char *appname = "c:\mytest.exe";
You need to escape the backslash with another backslash:
char *appname = "c:\\mytest.exe";
> When I call :
>
> CreateProcess(appname, args, .......);
>
> When application "mytest.exe" calls ParamCount(), the value is Zero.
There is a known bug I found in the ParamCount() and ParamStr() functions a
couple of months ago (reported as QC #3946). It is a mix of both an OS
glitch coupled with a VCL parsing bug on top of it.
When calling CreateProcess() with both the lpApplicationName and
lpCommandLine parameters filled in, the OS does not include the
lpApplicationName as part of the command-line that is returned by the
GetCommandLine() function. However, the VCL makes the assumption that the
lpApplicationName will always be present as the first parameter, so the
parsing functions are hard-coded to always ignore the first parameter. But
that is not the case in this scenerio. Since the OS does not always return
the lpApplicationName, and the VCL is actively ignoring the first parameter
being parsed regardless, and you are only passing in actual parameter in
your example, that is why the count comes out as 0.
> char *fullcmdline = "c:\mytest.exe /myarg1";
> CreateProcess(NULL,fullcmdline,.....);
> This works,
That is what you have to do to workaround the issue for the time being, yes.
Gambit
Technical Details
Message-ID:
<3ed7d9d1$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!cyclone.bc.net!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3ed7bb90@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,bd638ff0f0e40f6 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-05-30 15:54:23 PST From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3ed7bb90@newsgroups.borland.com> Subject: Re: CreateProcess() passing cmd line args Date: Fri, 30 May 2003 15:26:01 -0700 Lines: 41 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 207.175.226.26 Message-ID: <3ed7d9d1$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1054333393 207.175.226.26 (30 May 2003 15:23:13 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!cyclone.bc.net!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail