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;

相关阅读 >>

paramstr返回运行当行程序的某个参数

Delphi中实现控件的拖拽

Delphi 为richedit设置行号

Delphi splitstring 字符串分割成字符串组

Delphi 提升Delphi 启动加载速度

Delphi ansicontainstext 是否包含子串

Delphi xe5开发的android手机截屏功能

Delphi 网上获取北京时间idhttpserver and idhttp 使用 encoding utf8

Delphi webbrowser添加到收藏夹

Delphi实现抓屏压缩并保存桌面图片

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



打赏

取消

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

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

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

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

评论

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