Looking for Delphi 7 code to detect if a program is started with administrator rights?

后端 未结 7 468
隐瞒了意图╮
隐瞒了意图╮ 2020-12-30 11:09

I am looking for working (obviously) Delphi 7 code so I can check whether my program is started with administrator rights<

7条回答
  •  萌比男神i
    2020-12-30 11:26

    program Project1;
    
    {$APPTYPE CONSOLE}
    
    uses
      Windows,
      ShellAPI;
    
    // high-level wrapper, see Ian Boyd's answer for details on this function
    function IsUserAnAdmin(): BOOL; external shell32;
    
    begin
      if IsUserAnAdmin() then
        Writeln('TEH R00T OMG')
      else
        Writeln('rtfmnoobkthx');
    
      Readln;
    end.
    

提交回复
热议问题