zoukankan      html  css  js  c++  java
  • delphi 运行时提升软件到管理员权限

    //以管理员身份运行
    procedure RunAsAdmin(hWnd: HWND; aFile: string; aParameters: string);
    var
    sei: TShellExecuteInfoA;
    begin
    FillChar(sei, SizeOf(sei), 0);
    sei.cbSize := SizeOf(sei);
    sei.Wnd := hWnd;
    sei.fMask := SEE_MASK_FLAG_DDEWAIT or SEE_MASK_FLAG_NO_UI;
    sei.lpVerb := 'runas';
    sei.lpFile := PChar(aFile);
    sei.lpParameters := PChar(aParameters);
    sei.nShow := SW_SHOWNORMAL;
    if not ShellExecuteEx(@sei) then
    RaiseLastOSError;
    end

    //把按钮设置成需要管理员运行样式,也就是加个图标到按钮上
    procedure SetElevationRequireState(aControl: TWinControl; Requiered: Boolean);
    const
    BCM_FIRST = $1600;//Button control messages
    BCM_SETSHILED = BCM_FIRST + $000C;
    var
    lRequired: Integer;
    begin
    lRequired := Integer(Requiered);
    SendMessage(aControl.Handle, BCM_SETSHIELD, 0, lRequired);
    end;

  • 相关阅读:
    [面试题]什么是面向对象编程
    面向对象编程的新手理解
    Object of type type is not JSON serializable
    STL---map
    STL---llist
    Div标签使用inline-block有间距
    STL---vector
    KMP算法
    算法06
    算法05
  • 原文地址:https://www.cnblogs.com/blogpro/p/11453656.html
Copyright © 2011-2022 走看看