by steve brigden (1 Submission)
Category: Registry
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating:
(38 Votes)
Who says you cant write to the registry without API?
This code is fast,smooth, and refreshes the registry instantly.
This is speed at work!
Assumes
just create a 'Reg File' call it Reg.Reg' for simplicity in keeping with the code.
Place it in the root dir: eg: c:\reg.Reg
paste the code straight into your form and away you go.
This function is great!
API DeclarationsNot Likely
Function SetDwordKeyValue(Hkey As String, SubKey As String, Keyname As String, Dword As String, Value As String)
Dword = "=dword:"
A$ = "REGEDIT4" & vbCrLf & "[" & Hkey & "\" & SubKey & "]" & vbCrLf & """" & Keyname & """" & Dword & Value
Open "c:\reg.reg" For Output As 1'create a 'Reg file and name it: 'Reg.reg
Print #1, A$
Close #1
ret = Shell("regedit.exe /s " & "c:\reg.reg", 0)
Kill "c:\reg.reg"
End Function
Sub DoIt(rtn As Boolean)
'Disable/Re-enable Regedit.exe
If rtn = True Then
ret = SetDwordKeyValue("HKEY_CURRENT_USER", "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableRegistryTools", "", "00000001")
Else
ret = SetDwordKeyValue("HKEY_CURRENT_USER", "\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableRegistryTools", "", "00000000")
End If
End Sub
Private Sub Form_Load()
'Writing to the Registry with no API's! What! No joke, It can be done!
'Changing this value to True Disables Regedit.Exe & Vice Versa.
'Comments:[email protected]
DoIt False
End Sub