有的.exe可以直接調用(例如下面代碼中的wifi.exe);有時候不可以,我就想了個辦法,先生成.exe的快捷方式,然後調用快捷方式就可以了(例如下面代碼中的registration)。整體代碼如下:
#include <stdio.h>
#include <stdlib.h>#include <windows.h>
#include <shellapi.h>
#include <iostream>
#include<fstream>
#include<string>
#include<iostream>
#include<vector>
using namespace std;
int main(void)//可能有一點點問題,假如registration會顯示很多圖片,然後由於並行,小部分文件夾會沒有數據,後期再添加數據!!!一般來說沒有問題。
{
// system("C:\\Users\\du\\Desktop\\wifi.exe");
HINSTANCE hNewExe = ShellExecuteA(NULL, "open", "C:\\Users\\du\\Desktop\\registration", NULL, NULL, SW_SHOW);
// HINSTANCE hNewExe = ShellExecuteA(NULL, "open", "C:\\Users\\du\\Desktop\\register_package\\3dFaceRegistration.exe", NULL, NULL, SW_SHOW);這樣不行會有問題
if ((DWORD)hNewExe <= 32)
{
printf("return value:%d\n", (DWORD)hNewExe);
}
else
{
printf("successed!\n");
}
return 1;
}