Windows Programming: Launching executable (EXE) program code (c + +)

Source: Internet
Author: User

Start the executable (EXE) program by entering the program location, using the Windows CreateProcess () function.

An example is the invocation of a pre-production executable (EXE) program.

Code:

* * * main.cpp * * Created on:2014.06.08 * author:spike//*vs 2012*/#include <iostre  
      
Am> #include <windows.h> using namespace std; BOOL StartProcess (const std::string name_) {startupinfo si;//Parameter Settings memset (&si, 0, sizeof (STARTUPINFO)  
    );  
    SI.CB = sizeof (STARTUPINFO);  
    Si.dwflags = Startf_useshowwindow;  
      
    Si.wshowwindow = Sw_show; Process_information Pi; 
    The argument ends/*printf ("Please enter the name of process to start:"); 
    std::string name; CIN >> name;*/if (!  CreateProcess (null, (LPSTR) name_.c_str (), NULL, NULL, FALSE, 0,NULL,NULL,&AMP;SI,&AMP;PI)) {cout<< "Create error! "  
        <<endl;  
    return false; else {cout<< "Create sucess!"  
    <<endl;  
return true;  
      
    int main () {const std::string name = ' D:/test/image.exe ';  
        if (!startprocess (name)) {cout << "Start Process error!" << Endl;  
return 0; }

Note: Image.exe is a pre-production executable (EXE) program.

Author: csdn Blog spike_king

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/cplus/

Related Article

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.