delphi 提升进程权限


本文整理自网络,侵删。

 function AdjustProcessPrivilege(ProcessHandle: THandle; Token_Name: PChar): boolean;
var
Token: cardinal;
TokenPri: _TOKEN_PRIVILEGES;
ProcessDest: int64;
l: DWORD;
begin
Result := False;
if OpenProcessToken(ProcessHandle, TOKEN_Adjust_Privileges, Token) then
begin
if LookupPrivilegeValue(nil, Token_Name, ProcessDest) then
begin
TokenPri.PrivilegeCount := 1;
TokenPri.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
TokenPri.Privileges[0].Luid := ProcessDest;
l := 0;
if AdjustTokenPrivileges(Token, False, TokenPri, sizeof(TokenPri), nil, l) then
Result := True;
end;
end;
end;

调用时使用AdjustProcessPrivilege(GetCurrentProcess,'SeDebugPrivilege');
即可开启当前程序的调试权限。

相关阅读 >>

Delphi 中string字符串转换byte[]字节数组

Delphi-xe5-开发 android uri简介

Delphi应用程序 paramstr()带有参数

Delphi 把pf8bit位图变换成pf24bit位图

Delphi 文本转成图片

Delphi截取技巧 lastdelimiter

Delphi 先加载原内容在写入增加新内容

Delphi 抓图后打印这张图片,弹出打印属性框

Delphi pchar和array [0..255] of char的区别

Delphi twebbrowser出现 method pastehtml not supported by automation object 解决方法

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



打赏

取消

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

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

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

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

评论

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