About calling other EXE files in VC

Source: Internet
Author: User

Call notepad. Webpage

Winexec ("notepad.exe", sw_show );// Open notepad
Winexec ("d :\\ Program Files \ test \ test.exe", sw_showmaximized); // open test.exe in simplified format.

 

ShellExecute (null, "open", "C: \ test.txt", null, null, sw_shownormal); // open the c: \ test.txt File
ShellExecute (null, "open", "iexplore.exe", "http://www.google.com ",/Null, null, sw_shownormal); // open the webpage www.google.com
ShellExecute (null, "Explore", "d: \ c ++", null, null, sw_shownormal); // open the Directory D: \ c ++
ShellExecute (null, "print", "C: \ test.txt", null, null, sw_hide); // print the file c: \ test.txt
ShellExecute does not support targeted output.

 

Winexec ("d :\\ Program Files \ test \ test.exe", sw_showmaximized );

ShellExecute (null, "open", "C: \ test.txt", null, null, sw_shownormal );
Bool fret = CreateProcess ("D: \ putty.exe", null, null, false, null, & Si, & PI );
 
How to call an EXE file in a VC program
ShellExecute (this-> m_hwnd, "open", "notepad.exe ",
   "C: \ Scandisk. log", "", sw_show );
 

Create an independent sub-process. The sub-processes created by the following code are independent.

Bool ret; process_information PI; startupinfo Si; SI. CB = sizeof (SI); SI. wshowwindow = sw_shownormal; ret = CreateProcess (_ T ("C: \ xx.exe"), null, null, false, 0, normal_priority_class, null, null, & Si, & PI ); if (RET) {closehandle (Pi. hthread); closehandle (Pi. hprocess);} // show in notepadprocess_information PI; startupinfo Si; // initialization variable memset (& Si, 0, sizeof (SI); SI. CB = sizeof (SI); SI. wshowwindow = sw_show; SI. dwflags = startf_us Eshowwindow; // open the Notepad program cstring myexe = "notepad.exe" + errfile; lpstr pexe; pexe = (lpstr) (lpctstr) (myexe); bool fret = CreateProcess (null, // "C :\\ winnt \ notepad.exe disterror. err ", pexe, null, null, false, normal_priority_class | create_new_console, null, null, Si, Pi); If (! Fret) {// creation failed. The error message MessageBox ("error: An error occurred while outputting the result to the file! "," Output result ", mb_iconerror );}

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.