Start other EXE programs in the MFC Program

Source: Internet
Author: User
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 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.