Announcement

Collapse
No announcement yet.

CheckElevationEnabled

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CheckElevationEnabled

    CheckElevationEnabled: Check if UAC is enabled on a system, undocumented, Seven+

    Pierre

    Code:
    #COMPILE EXE '#Win 8.04#
    #DIM ALL
    #INCLUDE "Win32Api.inc"
     
    DECLARE FUNCTION CheckElevationEnabled LIB "Kernel32.dll" ALIAS "CheckElevationEnabled" _
    (BYREF UacEnabled AS DWORD) AS LONG 'Seven+
     
    GLOBAL hDlg AS DWORD
     
    %LabelDescription = 101
    %LabelShowUac     = 102
    %ButtonCheckUac   = 201
    '______________________________________________________________________________
     
    CALLBACK FUNCTION DlgProc
     LOCAL UAC AS LONG
     
     SELECT CASE CBMSG
       CASE %WM_COMMAND
         SELECT CASE CBCTL
           CASE %ButtonCheckUac
             IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
               CheckElevationEnabled(UAC)
               CONTROL SET TEXT hDlg, %LabelShowUac, _
               "UAC is" & IIF$(UAC, "", " not") & " enabled on this system"
             END IF
         END SELECT
      END SELECT
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION PBMAIN()
     LOCAL hIcon AS DWORD
     
     DIALOG FONT "Segoe UI", 9
     DIALOG NEW %HWND_DESKTOP, "CheckElevationEnabled", , , 200, 60, _
     %WS_CAPTION OR %WS_MINIMIZEBOX OR %WS_SYSMENU, 0 TO hDlg
     
     hIcon = ExtractIcon(GetModuleHandle(""), "Shell32.dll", 80)
     SetClassLong(hDlg, %GCL_HICON, hIcon)
     
     CONTROL ADD LABEL,  hDlg, %LabelDescription, "Check if UAC is enabled on this system", 5,  5, 190, 10, %SS_CENTER
     CONTROL ADD LABEL,  hDlg, %LabelShowUac,     "Undocumented api: Seven +",              5, 20, 190, 10, %SS_CENTER
     CONTROL ADD BUTTON, hDlg, %ButtonCheckUac,   "&CheckElevationEnabled",                50, 35, 100, 15
     
     DIALOG SHOW MODAL hDlg CALL DlgProc
     
     DestroyIcon(hIcon)
     
    END FUNCTION
    '______________________________________________________________________________
    '
    Last edited by Pierre Bellisle; 27 Aug 2021, 03:14 PM.
Working...
X