本文整理自网络,侵删。
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 thenbeginShowMessage('IsUserAnAdmin true');endelsebeginShowMessage('IsUserAnAdmin false');end;
end;
相关阅读 >>
Delphi ansicontainstext 是否包含子串
Delphi 网上获取北京时间idhttpserver and idhttp 使用 encoding utf8
更多相关阅读请进入《Delphi》频道 >>