🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to run another program

#12904
From: Giovanni Benintende
Date: Thu, 13 Nov 2003 07:04
32 lines
1912 bytes
"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: <3fb32d12@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!diablo.theplanet.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3fb31fce@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:09:52 PST
From: "Giovanni Benintende" <benint@gbsoft.it>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3fb31fce@newsgroups.borland.com>
Subject: Re: How to run another program
Date: Thu, 13 Nov 2003 08:04:49 +0100
Lines: 34
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300
NNTP-Posting-Host: 82.84.45.11
Message-ID: <3fb32d12@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1068707090 82.84.45.11 (12 Nov 2003 23:04:50 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!diablo.theplanet.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail