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图片上写水印文字函数

Delphi savelog 方便的记录日志

Delphixe win7、mssql2000、udl

Delphi webbrowser同时访问两个网址导致程序出错的解决办法

Delphi 双进程监控保护

Delphi xe8中的firemonkey应用程序将文本复制到剪贴板

Delphi xe 移动平台 showmodal 范例

Delphi tidhttp+tidssliohandlersocket+ssl

Delphi登陆验证方法

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



打赏

取消

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

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

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

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

评论

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