Start other EXE programs in the MFC Program
ShellExecute (null, "open", "http://www.sina.com.cn", null, null, sw_shownormal );
// ShellExecute (null, "open", "C: \ Documents and Settings \ Administrator \ Desktop \ xq1 \ testchess0.exe", null, null, sw_shownormal );
You can also use a shellexecuteex function, where you can set the working directory path.
Some colleagues used shellexecutebut did not use the working directory path of .exe. Therefore, some images cannot be called.
Reading ranking comment ranking
Q: How to open an application?
ShellExecute (this-> m_hwnd, "open", "calc.exe", "", "", sw_show); or ShellExecute (this-> m_hwnd, "open", "notepad.exe ", "C: \ mylog. log "," ", sw_show); as you can see, I have not passed the complete path of the program.
Q: How do I open a file related to the same system program?
ShellExecute (this-> m_hwnd, "open", "C: \ abc.txt", "", "", sw_show );
Q: How to open a webpage?
ShellExecute (this-> m_hwnd, "open", "", sw_show );
Q: How to activate related programs and send emails?
ShellExecute (this-> m_hwnd, "open", "mailto: nishinapp@yahoo.com", "", "sw_show );
Q: How do I print documents with a system printer?
ShellExecute (this-> m_hwnd, "print", "C: \ abc.txt", "", "", sw_hide );
Q: How can I use the system search function to find a specified file?
ShellExecute (m_hwnd, "find", "d: \ Nish", null, null, sw_show );
Q: How do I start a program until it finishes running?
Shellexecuteinfo shexecinfo = {0 };
Shexecinfo. cbsize = sizeof (shellexecuteinfo );
Shexecinfo. fmask = see_mask_nocloseprocess;
Shexecinfo. hwnd = NULL;
Shexecinfo. lpverb = NULL;
Shexecinfo. lpfile = "C: \ myprogram.exe ";
Shexecinfo. lpparameters = "";
Shexecinfo. lpdirectory = NULL;
Shexecinfo. nshow = sw_show;
Shexecinfo. hinstapp = NULL;
Shellexecuteex (& shexecinfo );
Waitforsingleobject (shexecinfo. hprocess, infinite );
Or:
Process_information processinfo;
Startupinfo; // This is an [in] Parameter
Zeromemory (& startupinfo, sizeof (startupinfo ));
Startupinfo. cb = sizeof startupinfo; // only compulsory field
If (CreateProcess ("C: \ winnt \ notepad.exe", null,
Null, null, false, 0, null,
Null, & startupinfo, & processinfo ))
{
Waitforsingleobject (processinfo. hprocess, infinite );
Closehandle (processinfo. hthread );
Closehandle (processinfo. hprocess );
}
Else
{
MessageBox ("the process cocould not be started ...");
}
Q: How do I display attributes of a file or folder?
Shellexecuteinfo shexecinfo = {0 };
Shexecinfo. cbsize = sizeof (shellexecuteinfo );
Shexecinfo. fmask = see_mask_invokeidlist;
Shexecinfo. hwnd = NULL;
Shexecinfo. lpverb = "properties ";
Shexecinfo. lpfile = "C: \"; // can be a file as well
Shexecinfo. lpparameters = "";
Shexecinfo. lpdirectory = NULL;
Shexecinfo. nshow = sw_show;
Shexecinfo. hinstapp = NULL;
Shellexecuteex (& shexecinfo );