🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

launching separate program

#9144
From: Blake Young
Date: Wed, 28 Jul 2004 15:32
53 lines
2600 bytes
The only other time I've launched a separate program from my main program
was when I called a console application from my GUI to do some processing.
In that case, I did the following:

    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

    if( !CreateProcess( NULL,
        "MyChildProcess",
        NULL,
        NULL,
        FALSE,
        0,
        NULL,
        NULL,
        &si,
        &pi )
    )
    {
        ErrorExit( "CreateProcess failed." );
    }

    // Wait until child process exits.
    WaitForSingleObject( pi.hProcess, INFINITE );

    // Close process and thread handles.
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );

The only problem now is that I want to be able to call an application and
have it live separately from the calling program. I don't want to wait for
it to end and then close the handle and thread, I need to just launch it and
then forget about it. I intended on just removing the WaitForSingleObject
and CloseHandle calls, but I read in the SDK where it says:

When you no longer need these handles, close them by using the CloseHandle
function.

If I remove those lines, my original program won't ever know when the
external program has finished execution and the handles will never be
closed. I'm not sure what implications this will have; what if the user
continues launching this external program over and over without closing
them? Maybe this isn't a big problem to begin with...I just wanted to check.

Also, this external program that gets launched should remain running even if
the original program is terminated.

Any help is appreciated.
Thanks.
Technical Details
Message-ID: <4107c722$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!fr.ip.ndsoftware.net!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,4306aa7d734acfa6,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Blake Young" <blakeyoung@mail.utexas.edu.NOSPAM>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: launching separate program
Date: Wed, 28 Jul 2004 10:32:45 -0500
Lines: 55
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 129.106.240.28
Message-ID: <4107c722$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1091028770 129.106.240.28 (28 Jul 2004 08:32:50 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail