#include <iostream>
#include<windows.h>
using namespace std;
int main()
{
    TCHAR szCmdLine[] = { TEXT("d://test//test.exe my") };
    STARTUPINFO si;
    memset(&si, 0, sizeof(STARTUPINFO));
    si.cb = sizeof(STARTUPINFO);
    si.dwFlags = STARTF_USESHOWWINDOW;
    si.wShowWindow = SW_SHOW;
    PROCESS_INFORMATION pi;
    if (!CreateProcess(NULL, szCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
    {
        cout << "Create Fail!" << endl;
        exit(1);
    }
    else
    {
        cout << "Sucess!" << endl;
        exit(1);
    }
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
    return 0;
}
#include "stdafx.h"
 #include <Shlwapi.h>
#include <io.h>
#include <set>
#include <sys/stat.h>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    ZeroMemory(&si, sizeof(si));
    si.cb = sizeof(si);
    ZeroMemory(&pi, sizeof(pi));
 
    si.dwFlags = STARTF_USESHOWWINDOW;  // 指定wShowWindow成员有效
    si.wShowWindow = SW_HIDE;          // 此成员设为TRUE的话则显示新建进程的主窗口
    TCHAR szGetInstallSoftInfoPath[MAX_PATH] = {0};
    TCHAR szFilePath[MAX_PATH]={0};
    _tcscpy_s(szGetInstallSoftInfoPath,MAX_PATH, _T("HtUpdate.exe -u"));
    _tcscpy_s(szFilePath,MAX_PATH,  _T("C:\\Program Files (x86)\\huatechsec\\HtUpdate.exe -u"));
 
    BOOL bRet = CreateProcess(NULL, szFilePath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
    if (!bRet)
    {   
        std::cout<<"error"<<std::endl;
    }
    WaitForSingleObject(pi.hProcess, INFINITE);
    CloseHandle(pi.hThread);
    CloseHandle(pi.hProcess);
    system("PAUSE");
//  ShellExecute(NULL,_T("open"), _T("C:\\Program Files (x86)\\huatechsec\\HtUpdate.exe"), _T("-u"), NULL, SW_HIDE);
    return 0;
}
最后修改:2021 年 01 月 31 日 09 : 36 PM
如果觉得我的文章对你有用,请随意赞赏