void prompt(LPWSTR szCmd) { TCHAR szModuleName[MAX_PATH]; STARTUPINFO si = { 0 }; PROCESS_INFORMATION pi = { 0 }; GetModuleFileName(NULL, szModuleName, MAX_PATH); CreateProcess(NULL, szCmd, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi); WaitForSingleObject(pi.hProcess, INFINITE); CloseHandle(pi.hThread); CloseHandle(pi.hProcess); }
使用方法:
WCHAR cmd[] = { L"ping www.baidu.com" }; prompt(cmd);
注意事项:阻塞方法
标签:NULL,prompt,cmd,c++,szCmd,PATH,pi,弹窗 From: https://www.cnblogs.com/laremehpe/p/17730133.html