zoukankan      html  css  js  c++  java
  • AdminCMD

    program AdminCMD;
    
    {$APPTYPE CONSOLE}
    
    uses
      Windows,
      ShellApi,
      SysUtils;
    
    function RunAsAdmin(const iExeName, iParam: String): Boolean;
    var
      SEI: TShellExecuteInfo;
    begin
      Result := False;
    
      if (CheckWin32Version(6)) then
      begin
        ZeroMemory(@SEI, SizeOf(SEI));
    
        with SEI do
        begin
          cbSize := SizeOf(SEI);
          Wnd := 0;
          fMask := SEE_MASK_FLAG_DDEWAIT or SEE_MASK_FLAG_NO_UI;
          lpVerb := 'runas';
          lpFile := PChar(iExeName);
          lpParameters := PChar(iParam);
          nShow := SW_SHOW;
        end;
    
        Result := ShellExecuteEx(@SEI);
      end;
    end;
    
    var
      CmdPath: String;
    begin
      CmdPath := StringOfChar(#0, MAX_PATH);
      ExpandEnvironmentStrings(
        PChar('%ComSpec%'),
        PChar(CmdPath),
        Length(CmdPath));
    
      CmdPath := Trim(CmdPath);
    
      RunAsAdmin(CmdPath, '');
    end.

    http://www.lsworks.net/article/99.html

  • 相关阅读:
    C++防止头文件反复包括
    yppasswd, ypchfn, ypchsh
    yes
    Yacc
    xxd
    xpdf -Portable Document Format(PDF)文件阅读器
    xinetd
    xargs
    x25, PF_X25
    write -在一个文件描述符上执行写操作
  • 原文地址:https://www.cnblogs.com/findumars/p/4998874.html
Copyright © 2011-2022 走看看