khawar
March 28th, 2002, 06:34 AM
How can i call a exefile in C++
|
Click to See Complete Forum and Search --> : .exe file call in C++ khawar March 28th, 2002, 06:34 AM How can i call a exefile in C++ hugo123 March 28th, 2002, 07:39 AM I think you can call ShellExecute, look in msdn for more information about this fonction. If this answer does not satisfy you, you can go to the Visual C++ forum. salman108 April 10th, 2002, 04:21 AM calling an EXE directly is hard, and very trouble some, cose of the ting with memory models, the neater way to do is , 1. make a dll of the exe u want to call. 2. create a theread and run the foreign object in it. calling an exe directly in a one line functoin is allmost impossible there is a function availbel called dosexec or soem ting of the sort, it is in the dos.h file, check with that. I know it is possible to execute DOS commands from the program, see under that for help, or the Borland C, help Jianhong Lu April 12th, 2002, 05:42 PM In Microsoft's MSDN there is a topic about how to create a process (program). I attached as follow. /*******************************************************/ Creating Processes The CreateProcess function creates a new process, which runs independently of the creating process. However, for simplicity, the relationship is referred to as a parent-child relationship. The following code fragment demonstrates how to create a process. #include <stdio.h> #include <Windows.h> void main( VOID ) { STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); // Start the child process. if( !CreateProcess( NULL, // No module name (use command line). "MyChildProcess", // Command line. NULL, // Process handle not inheritable. NULL, // Thread handle not inheritable. FALSE, // Set handle inheritance to FALSE. 0, // No creation flags. NULL, // Use parent's environment block. NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi ) // Pointer to PROCESS_INFORMATION structure. ) { ErrorExit( "CreateProcess failed." ); } // Wait until child process exits. WaitForSingleObject( pi.hProcess, INFINITE ); // Close process and thread handles. CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); } If CreateProcess succeeds, it returns a PROCESS_INFORMATION structure containing handles and identifiers for the new process and its primary thread. The thread and process handles are created with full access rights, although access can be restricted if you specify security descriptors. When you no longer need these handles, close them by using the CloseHandle function. You can also create a process using the CreateProcessAsUser function. This function allows you to specify the security context of the user account in which the process will execute. /*******************************************************/ The functin ShellExecute or ShellExecuteEx is for Win95 and before. So try to run above function. Jianhong Lu Antony Placid April 15th, 2002, 03:07 AM you can use WinExec().. for more information refer MSDN Antony B Placid RHR Software Technologies MIDC, Andheri, Mumbai. Email:antonyp@rhrsoftinc.com Voice: +91 22 8395148 http://www.rhrsoftinc.com codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |