Tools Links Login

Write to Registry with No API

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!

Original Author: steve brigden

Assumptions

just create a 'Reg File' call it Reg.Reg' for simplicity in keeping with the code.
Place it in the root dir: eg: c: eg.Reg
paste the code straight into your form and away you go.
This function is great!

API Declarations

Not Likely

Code

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: eg.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: eg.reg", 0)
Kill "c: eg.reg"
End Function
Sub DoIt(rtn As Boolean)
'Disable/Re-enable Regedit.exe
If rtn = True Then
ret = SetDwordKeyValue("HKEY_CURRENT_USER", "SoftwareMicrosoftWindowsCurrentVersionPoliciesSystem", "DisableRegistryTools", "", "00000001")
Else
ret = SetDwordKeyValue("HKEY_CURRENT_USER", "SoftwareMicrosoftWindowsCurrentVersionPoliciesSystem", "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:Steve.Brigden@Usa.Net
DoIt False
End Sub

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 96 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.