Article View: borland.public.cppbuilder.nativeapi
Article #12905Re: How to run another program
From: Maurice Anderson
Date: Thu, 13 Nov 2003 07:35
Date: Thu, 13 Nov 2003 07:35
41 lines
2100 bytes
2100 bytes
Thank You Giovanni!! It worked and it saved me alot of ime.
"Giovanni Benintende" <benint@gbsoft.it> wrote in message
news:3fb32d12@newsgroups.borland.com...
>
> "Maurice Anderson" <mauriceanderson@hotmail.com> ha scritto nel messaggio
news:3fb31fce@newsgroups.borland.com...
> > I would like to run/start a GUI.exe or Console.exe program in the
OnClick
> > event of a button. Anyone know how to do this?
> >
> >
>
> Maurice, here is complete function:
>
> bool SpawnExec(HWND Handle, String CmdLine, bool Minimized, bool Wait)
> {
> STARTUPINFO si;
> PROCESS_INFORMATION pi;
> DWORD iExitCode;
> bool bRet;
>
> if (Minimized)
> ShowWindow(Handle, SW_MINIMIZE);
> ZeroMemory(&si, sizeof(si));
> bRet = CreateProcess(NULL, CmdLine.c_str(), NULL, NULL, false,
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
> if (bRet) {
> CloseHandle(pi.hThread);
> if (Wait)
> WaitForSingleObject(pi.hProcess, INFINITE);
> GetExitCodeProcess(pi.hProcess, &iExitCode);
> // iExitCode contains the process exit code
> }
> CloseHandle(pi.hProcess);
> if (Minimized)
> ShowWindow(Handle, SW_SHOWNORMAL);
> return bRet;
> }
>
>
Technical Details
Message-ID:
<3fb33356$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3fb31fce@newsgroups.borland.com> <3fb32d12@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,7300c6a35bdece53 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-11-12 23:39:18 PST From: "Maurice Anderson" <mauriceanderson@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3fb31fce@newsgroups.borland.com> <3fb32d12@newsgroups.borland.com> Subject: Re: How to run another program Date: Wed, 12 Nov 2003 23:35:08 -0800 Lines: 43 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 64.30.203.223 Message-ID: <3fb33356$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1068708694 64.30.203.223 (12 Nov 2003 23:31:34 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail