string getTime() { time_t timep; time(&timep); char tmp[64] = {0}; //获取时间 时分秒 strftime(tmp, sizeof(tmp), "%H:%M:%S", localtime(&timep)); return tmp; } string ltime_end = getTime(); if (ltime_end == "00:00:30") { for (int i = 0; i < 10; i++) { DWORD ldatasnappid = GetProcessIDByName("ES_Svr.exe") ; if (ldatasnappid != 0) { string ss = "TaskKill /F /PID " + to_string(ldatasnappid); WinExec(ss.c_str(),SW_SHOWMINIMIZED); Sleep(3000); } } DWORD ldatasnappid2 = GetProcessIDByName("ES_SvrWork64.exe") ; if (ldatasnappid2 == 0) { string datasnap1 = "D:\adg\dataap\Snapvr\ES_Svr.exe"; string datasnap2 = "D:\adg\datnap\Snap\ES_Svr.exe"; string datasnap3 = "D:\adg\daap\Sna\ES_Svr.exe"; TCHAR CurrentPath[MAX_PATH]={0}; GetCurrentDirectory(MAX_PATH,CurrentPath); SetCurrentDirectory("D:\adg\hgf\fgh\");//改成你想调用的路径 WinExec(datasnap1.c_str(),SW_SHOWMINIMIZED); SetCurrentDirectory(CurrentPath);//设置回原来主程序的当前路径 Sleep(5000); GetCurrentDirectory(MAX_PATH,CurrentPath); SetCurrentDirectory("D:\adg\asd\asd\");//改成你想调用的路径 WinExec(datasnap2.c_str(),SW_SHOWMINIMIZED); SetCurrentDirectory(CurrentPath);//设置回原来主程序的当前路径 Sleep(5000); GetCurrentDirectory(MAX_PATH,CurrentPath); SetCurrentDirectory("D:\adg\dsa\dsa\");//改成你想调用的路径 WinExec(datasnap3.c_str(),SW_SHOWMINIMIZED); SetCurrentDirectory(CurrentPath);//设置回原来主程序的当前路径 } }