Call other programs
He Zhidan
Winexec prototype: Uint Winexec (LPCSTR LPCMDLINE, / / Address of Command Line uint Ucmdshow // Window Style for New Application); for the 16-bit operating system and compatibility system. For example: Winexec ("Notepad.exe f: // Call Program .txt ", sw_show; Winexec (" NOTEPAD.EXE ", SW_SHOW); Different parameters are separated by spaces, and there is no space in the path, and most of the programs are installed by default" ... / program files /. .. ", such as Word, this greatly limits the application range of Winexec. The above can be used: 1. The program is located. 2. Current path .3, system directory, you can get .4, windows directory. You can use GetSystemDirectory. 4, windows directory. Get it with ThegetWindowsDirectory. 5, the directory set in the environment variable.
SHELLEXECUTE prototype: hinstance shellexecute (hwnd hwnd, // parent window handle LPCTSTSTSTR LPOPERATION, // Operation, "Open", "Print", "Explore" lpctstr lpfile, // file name, front plus path LPCTSTR LPPARETERS, // parameter LPCTSTR LPDIRECTORY, / / Default Folder INT NSHOWCMD // Display Mode);
Open an application Shellexecute (this-> m_hwnd, "open", "cagc.exe", ",", sw_show); or shellexecute (this-> m_hwnd, "open", "notepad.exe", "c : /Mylog.log "," ", sw_show);
Open a document with system programs Shellexecute (this-> m_hwnd, "open", "c: /abc.txt", ",", sw_show);
Activate related procedures, send emailshellexecute (this-> m_hwnd, "open", "mailto: nishinapp@yahoo.com", ",", ", sw_show);
Print document Shellexecute (this-> m_hwnd, "print", "c: /abc.txt", ",", ",", "
Example of LPParameters: 1. Create a program that can accept parameters call.exe, add the following code: Bool ccallapp :: InitInstance () {int n = __ARGC; for (int i = 1; i
Startupinfo Startupinfo; Memset (& Startupinfo, 0, Sizeof (Startupinfo); Startupinfo.cb = SizeOf (StartupInfo);
Example: // maximize the program's most startupInfo.dwFlags start | = STARTF_USESHOWWINDOW; startupInfo.wShowWindow = SW_SHOWMAXIMIZED; // run .... exe PROCESS_INFORMATION ProcessInfo; BOOL bCreate = :: CreateProcess ( "f: //call.exe" , // 1 2 3 4 ", NULL, NULL, NULL, FALSE, 0, NULL, NULL, & Startupinfo, & ProcessInfo;
// Wait until Call.exe executes WaitForsingleObject (ProcessInfo.hprocess, 1000000); MessageBox ("The call is over!");