How to execute another exe from a C++ program in Windows

前端 未结 5 1360
迷失自我
迷失自我 2020-12-10 07:06

I want my C++ program to execute another .exe, in Windows. How would I do this? I am using Visual C++ 2010.

Here is my code

#include \"stdafx.h\"
#in         


        
5条回答
  •  误落风尘
    2020-12-10 07:51

    I believe this answer should work with different programs, I tested it with Chrome.

    // open program.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    #include "string"
    
    using namespace std;
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        string command = "start chrome https://www.google.com/";
        system(command.c_str());
    
        return 0;
    }
    

提交回复
热议问题