Change Windows Registered Name

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 1 CommandButton to your form (named Command1),
'And 1 TextBox (named Text1).
'Type in the TextBox you desirable windows registered name.
'After that press the button. To see the results, right-click on 'My Computer'
'Icon on your desktop.
'Insert this code to the module :

Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" _
(ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As _
Long, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Declare Function RegFlushKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Const HKEY_LOCAL_MACHINE = &H80000002

'Insert this code to your form:

Sub WriteRegistry(ByVal Group As Long, ByVal Section As String, ByVal Key As _
String, NewVal As String)
Dim lResult As Long, lKeyValue As Long
Dim InLen As Long
On Error Resume Next
lResult = RegOpenKey(Group, Section, lKeyValue)
InLen = Len(NewVal)
lResult = RegSetValueEx(lKeyValue, Key, 0&, 1&, NewVal, InLen)
lResult = RegFlushKey(lKeyValue)
lResult = RegCloseKey(lKeyValue)
End Sub

Private Sub Command1_Click()
WriteRegistry HKEY_LOCAL_MACHINE, _
"SOFTWARE\Microsoft\Windows\CurrentVersion", "RegisteredOwner", Text1
End Sub

Go Back