Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run exe form a button

Status
Not open for further replies.

Betsie

Technical User
Sep 18, 2001
2
ZA
I would like to know how to open or run an exe file from a C++ form.
 
Look at thread101-85540 and thread101-34713. James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 

this will execute your .exe.


void __fastcall TForm1::Button1OnClick(TObject * Sender)
{

const char * WinShut = "C:\\MyDir\\MyDir\\MyApp.exe";


//selects the program and how to use it
SHELLEXECUTEINFO exeinfo;
memset(&exeinfo, 0, sizeof(exeinfo));
exeinfo.cbSize = sizeof(exeinfo);
exeinfo.lpVerb = "open";
exeinfo.lpFile = WinShut;
exeinfo.fMask = SEE_MASK_NOCLOSEPROCESS;
exeinfo.nShow = SW_SHOWDEFAULT;

if (!ShellExecuteEx(&exeinfo))
{
MessageDlg(&quot;Could not open: Win.exe&quot;, mtError, TMsgDlgButtons() << mbOK,0);
return;
}
} Cyprus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top