🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #2828

Re: Launching notepad etc

#2828
From: Bob Gonder
Date: Tue, 02 Jan 2007 16:35
44 lines
2368 bytes
Colin B Maharaj wrote:

>You see when I call an external program, it seems to
>be attached somehow with the calling process in that
>If I stop my application (in the BCB IDE) my
>application does not close unless all called processes
>are stopped.

I think that might be an IDE issue, not an issue with your code.

But, there are a few things I would change...

>   STARTUPINFO             siStartInfo;
>   // Set up members of STARTUPINFO structure.
>   siStartInfo.cb          = sizeof(STARTUPINFO);
>   siStartInfo.lpReserved  = NULL;
>   siStartInfo.lpReserved2 = NULL;
>   siStartInfo.cbReserved2 = 0;
>   siStartInfo.lpDesktop   = NULL;
>   siStartInfo.lpTitle     = Title;
>   siStartInfo.dwFlags     = 0;

Why aren't you setting All members to 0 ?
Easiest way to do the above is

   STARTUPINFO             siStartInfo = {sizeof(STARTUPINFO), 0};
   siStartInfo.lpTitle     = Title;

>   char *cmdln_str = new char [MAX_PATH];

Why are your putting this on the heap?
Faster is
	char	cmdln_str[MAX_PATH+1];

>   strncpy(cmdln_str, strCmdLine.c_str(), MAX_PATH);

Even faster would be to use strCmdLine.c_str() directly in the
CreateProcess call.

>     GetExitCodeProcess(piProcInfo.hProcess, &exitCode);

	Why are you doing this here?
There isn't much chance that the spawned application has even finished
initialization yet, let alone run to completion?
Technical Details
Message-ID: <md1lp2t6r4neju928a8g042vim25q2fo8i@4ax.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <459a3b8f$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,fec586f4dcaf98b5
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Launching notepad etc
Date: Tue, 02 Jan 2007 08:35:51 -0800
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <md1lp2t6r4neju928a8g042vim25q2fo8i@4ax.com>
References: <459a3b8f$1@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 69.69.87.117
X-Trace: newsgroups.borland.com 1167755711 69.69.87.117 (2 Jan 2007 08:35:11 -0800)
Lines: 46
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail