🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Launching notepad etc

#2826
From: Colin B Maharaj
Date: Tue, 02 Jan 2007 11:02
52 lines
2570 bytes
Hi all, firstly happy new year to everyone!
I want to launch a session of notepad and
have it separated from the calling application.

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.

here is my code......
void WinSystem2(const AnsiString& strCmdLine, char *Title)
{

   PROCESS_INFORMATION     piProcInfo;
   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;

   char *cmdln_str = new char [MAX_PATH];
   strncpy(cmdln_str, strCmdLine.c_str(), MAX_PATH);

   // Create the child process.
   bool success = CreateProcess(
     NULL,
     cmdln_str,
     NULL,           // process security attributes
     NULL,           // primary thread security attributes
     0,              // handles are inherited
     0,              // creation flags
     NULL,           // use parent's environment
     NULL,           // use parent's current directory
     &siStartInfo,   // STARTUPINFO pointer
     &piProcInfo);   // receives PROCESS_INFORMATION

    if (success == true)
    {                              // process handle
     CloseHandle(piProcInfo.hThread);
     DWORD exitCode;
     GetExitCodeProcess(piProcInfo.hProcess, &exitCode);
	CloseHandle(piProcInfo.hProcess);
    }
    delete cmdln_str;


}
Technical Details
Message-ID: <459a3b8f$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.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

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,fec586f4dcaf98b5,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 02 Jan 2007 07:02:27 -0400
From: Colin B Maharaj <noreply@myhost.com>
User-Agent: Thunderbird 1.5.0.9 (Windows/20061207)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Launching notepad etc
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 200.108.20.115
Message-ID: <459a3b8f$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1167735695 200.108.20.115 (2 Jan 2007 03:01:35 -0800)
Lines: 52
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.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