2.其他小内容合集

来源:互联网 发布:淘宝助理有没有手机版 编辑:程序博客网 时间:2024/05/21 11:06

要求编译出的程式打开时需求administrator权限:

VS 设置:Project->Properties->Configuration Properties->Linker->Manifest File->UAC Execution Level


=====================================================================================


调用控制台下命令,个人使用system(),

还有同事使用另一种较麻烦

// ShellExecuteEx function to launch cmd or executionDWORD CRunCmd::Execute(LPCSTR szExe, LPCSTR szCmd, LPCSTR szPath, bool bShowWindow, bool infinite){char szText[MAX_PATH] = "";SHELLEXECUTEINFOA   shExecInfo;DWORD exitCode = 0;BOOL success = FALSE;shExecInfo.cbSize= sizeof(SHELLEXECUTEINFOA);shExecInfo.fMask= SEE_MASK_NOCLOSEPROCESS;shExecInfo.hwnd= NULL;shExecInfo.lpVerb= NULL;shExecInfo.lpFile= szExe;shExecInfo.lpParameters= szCmd;shExecInfo.lpDirectory= szPath;if(bShowWindow == true)shExecInfo.nShow = SW_SHOW;elseshExecInfo.nShow = SW_HIDE;shExecInfo.hInstApp= NULL;success = ShellExecuteExA(&shExecInfo);if (success == FALSE){return GetLastError();//return 0;}   else{HANDLE hProcess = shExecInfo.hProcess;   if (infinite){WaitForSingleObject(hProcess, INFINITE);   GetExitCodeProcess(hProcess,&exitCode);}CloseHandle(hProcess);  return 1;}//return  exitCode;}

0 0
原创粉丝点击