delphi RunAsAdmin 运行程序并申请管理员权限


本文整理自网络,侵删。

 
procedure RunAsAdmin(const aFile: string; const aParameters: string = ''; Handle: HWND = 0);
var
  sei: TShellExecuteInfo;
begin
  FillChar(sei, SizeOf(sei), 0);

  sei.cbSize := SizeOf(sei);
  sei.Wnd := Handle;
  sei.fMask := SEE_MASK_FLAG_DDEWAIT or SEE_MASK_FLAG_NO_UI;
  sei.lpVerb := 'runas';
  sei.lpFile := PChar(aFile);
  sei.lpParameters := PChar(aParameters);
  sei.nShow := SW_SHOWNORMAL;

  if not ShellExecuteEx(@sei) then
    RaiseLastOSError;
end;




procedure TForm1.Button1Click(Sender: TObject);
begin
RunAsAdmin('D:\IDM6.30.2\IDM\IDMan.exe','',handle);
end;

相关阅读 >>

Delphi 跨平台的,在fmx中读取icon文件的每一帧到bitmap

Delphi实现win10下Delphi 10.3.1 inline hook 修改mac网卡地址之getadaptersaddresses

Delphi cxgrid使用小结

Delphi android检查互联网连接

Delphi 杨辉三角

Delphi idhttp post json

Delphi在桌面上显示文字代码

Delphi firemonkey在画布上绘制 imagelist图像

Delphi文件操作所涉及的一些函数

Delphi 查询当前进程的内存使用大小

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...