Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1463

[vb6.0] Pragmatically Enable/Disable notification and UAC

$
0
0
Hi,

This code will allow you to pragmatically enable/disable both the notification and the UAC

Code:

'Pragmatically enable/disable both the notification and the UAC
'Author: Nightwalker83
'Date: 19/07/2014
'http://aaronspehr.net/
Option Explicit

Private Declare Function RtlAdjustPrivilege Lib "NTDLL" (ByVal Privilege As Long, ByVal Enable As Boolean, ByVal Client As Boolean, WasEnabled As Long) As Long
Private Declare Function RegSetValueExA Lib "advapi32.dll" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Long, ByVal cbData As Long) As Long
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long

Public Sub DisableUac()
    Dim lKey As Long
   
    Call RtlAdjustPrivilege(17, True, True, 0)
    If RegOpenKeyEx(&H80000002, "SOFTWARE\Microsoft\Security Center", 0&, &H20000 Or &H2& Or &H4&, lKey) = 0& Then
        If (RegSetValueExA(lKey, "UACDisableNotify", 0, 4, 0, 4) = 0&) Then
            RegCloseKey lKey
        End If
    End If
    If RegOpenKeyEx(&H80000002, "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", 0&, &H20000 Or &H2& Or &H4&, lKey) = 0& Then
        If (RegSetValueExA(lKey, "EnableLUA", 0, 4, 0, 4) = 0&) Then
            RegCloseKey lKey
        End If
    End If
End Sub

Public Sub EnableUac()
    Dim lKey As Long
   
    Call RtlAdjustPrivilege(17, True, True, 0)
    If RegOpenKeyEx(&H80000002, "SOFTWARE\Microsoft\Security Center", 0&, &H20000 Or &H2& Or &H4&, lKey) = 0& Then
        If (RegSetValueExA(lKey, "UACDisableNotify", 0, 4, 1, 4) = 0&) Then
            RegCloseKey lKey
        End If
    End If
    If RegOpenKeyEx(&H80000002, "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", 0&, &H20000 Or &H2& Or &H4&, lKey) = 0& Then
        If (RegSetValueExA(lKey, "EnableLUA", 0, 4, 1, 4) = 0&) Then
            RegCloseKey lKey
        End If
    End If
End Sub


Nightwalker

Viewing all articles
Browse latest Browse all 1463

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>