Windows以管理员权限运行可附带执行参数
本帖最后由 星辰曲径 于 2025-5-8 01:01 编辑<火山程序 类型 = "通常" 版本 = 1 />
@ SHELLEXECUTEINFOW ExecInfo{ 0 };
@ ExecInfo.cbSize = sizeof(SHELLEXECUTEINFOW);
@ ExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
@ ExecInfo.lpVerb = L"runas";
@ ExecInfo.lpFile = @<文件路径>.GetText ();
@ ExecInfo.lpParameters = @<运行参数>.GetTextMaybeNull();
@ ExecInfo.lpDirectory = NULL;
@ ExecInfo.nShow = @<是否隐藏> ? SW_HIDE : SW_SHOWDEFAULT;
@ BOOL bSuccess = ::ShellExecuteExW(&ExecInfo);
@ if (bSuccess && ExecInfo.hProcess) {
@ WaitForSingleObject(ExecInfo.hProcess, INFINITE);
@ CloseHandle(ExecInfo.hProcess);
@ }
@ return bSuccess;
前排支持开源 前排支持开源
页:
[1]