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!

how do you call other programs from a c++ program? 1

Status
Not open for further replies.

tchkid832

Programmer
Dec 19, 2001
7
US
hi, 1st year comp. si. student,

I just wrote a real simple c++ program from class. I wrote a perl script to prep the input file for my c program. Once the perl is converted to and exe how can I include it in the c++ program?

-Peter
 
Do you want to "include" it like a library or "call" it from the C++ program?
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.
 
I do not want to include it, I want to know how to call it.
-Peter
 
#include <shellapi.hpp> //used with ShellExecute

void __fastcall TForm1::Image1Click(TObject *Sender)
{
char szPro1[160];
if(GetPrivateProfileString(&quot;BUTTON_1&quot;, &quot;1&quot;,
&quot;&quot;, szPro1, sizeof(szPro1), NewIniFile) > 2) {
char *s1 = szPro1;
fnsplit(s1,drive,dir,file1,ext);
char szDf1[160];
sprintf(szDf1, &quot;%s%s&quot;, drive, dir);
if(DirectoryExists(szPro1) == true) {
String S1;
S1 = ExtractShortPathName(szPro1);
ShellExecute(Form1->Handle, &quot;open&quot;, S1.c_str(), NULL, NULL, SW_SHOWNORMAL); }
else {
ShellExecute(Form1->Handle, &quot;open&quot;, szPro1, NULL, szDf1, SW_SHOWNORMAL); }
}
}

I hope this helps you to understand how the ShellExecute function is used.

 
This works for me

HWND Switch;
Switch = FindWindow( NULL , &quot;Program_Window_Name_Here&quot; );
if ( Switch )
BringWindowToTop(Switch);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top