Delphi 判断是否是系统管理员身份


本文整理自网络,侵删。

 
uses  Winapi.ShellAPI,
  Winapi.TlHelp32;

var
  hShell32: HMODULE = 0;
var
  _IsUserAnAdmin: function(): BOOL; stdcall = nil;

function CheckIsAdmin: Boolean;
begin
  if Assigned(_IsUserAnAdmin) then
    Result := _IsUserAnAdmin()
  else
  begin
    Result := True;
    if hShell32 = 0 then
      hShell32 := LoadLibrary(shell32);
    if hShell32 > HINSTANCE_ERROR then
    begin
      _IsUserAnAdmin := GetProcAddress(hShell32, 'IsUserAnAdmin');
      if Assigned(_IsUserAnAdmin) then
        Result := _IsUserAnAdmin();
    end;
  end;
end;


procedure TForm1.FormCreate(Sender: TObject);
begin

if CheckIsAdmin=true then
begin
ShowMessage('IsUserAnAdmin true');
end
else
begin
ShowMessage('IsUserAnAdmin false');
end;

end;

相关阅读 >>

Delphi气泡提示

Delphi 设置richedit的行间距

Delphi 字符串加密解密(不支持中文)

Delphi 中的包开发

Delphi 调用exitwindows 关闭系统

Delphi controls 属性与继承 tshape 类的小练习

Delphi getforegroundwindow 与 getactivewindow 的区别

Delphi窗体自适应分辨率

Delphi抓取qq聊天窗口实例

Delphi 检测程序有没有被dll注入的代码

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



打赏

取消

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

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

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

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

评论

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