Option Explicit
How come no matter what i do, it makes the value 2?Code:Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal HKey As Long) As Long Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal HKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal HKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long Private Sub SaveString(HKey As Long, Path As String, Name As String, Data As Variant) Dim KeyHandle As Long Dim RetVal As Long RetVal = RegCreateKey(HKey, Path, KeyHandle) RetVal = RegSetValueEx(KeyHandle, Name, 0&, 4, Data, 4) 'Will make it a dWord RetVal = RegCloseKey(KeyHandle) End Sub Public Sub Tick_Key() Debug.Print "Ticked" SaveString &H80000002, "System\CurrentControlSet\Control\LSA", "ForceGuest", 1 End Sub Public Sub Untick_Key() Debug.Print "Unticked" SaveString &H80000002, "System\CurrentControlSet\Control\LSA", "ForceGuest", 0 End Sub
If i set it to &HFFFFFFFF then it makes the value 3, but setting it to -1, brings it back to 2, that's so wierd.
I'm trying to work out how to make this value swap between 1 & 0.
Yes i've look and researched how to set dWords, but nothing has helped.




Reply With Quote