Selanjutnya saya bagikan untuk Anda full source code program VB 6.0 (Visual Basic 6.0) untuk mengganti Owner Name dan Organization pada Windows Anda. OK, tanpa basa-basi lagi langsung saja ke TKP (Tempat Kode Program).
- Buka VB 6.0 dan buat Project baru.
- Tambahkan 1 Module dan Copy Paste kode di bawah ini.
Private Const HKEY_LOCAL_MACHINE = &H80000002
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 RegCloseKey Lib _
"advapi32.dll" (ByVal Hkey 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 Const REG_SZ = 1
Private Const REG_DWORD = 4
Public Function ChangeWindowsOwner(OwnerName As String, _
Organization As String) As Boolean
On Error GoTo ErrorHandler
Dim bAns As Boolean
If OwnerName = "" Or Organization = "" Then
ChangeWindowsOwner = False
Exit Function
End If
bAns = SaveString(HKEY_LOCAL_MACHINE, _
"Software\Microsoft\Windows\CurrentVersion", _
"RegisteredOwner", OwnerName)
If bAns Then bAns = SaveString(HKEY_LOCAL_MACHINE, _
"Software\Microsoft\Windows\CurrentVersion", _
"RegisteredOrganization", Organization)
ChangeWindowsOwner = bAns
Exit Function
ErrorHandler:
ChangeWindowsOwner = False
End Function
Private Function SaveString(Hkey As Long, strPath As String, _
strValue As String, strdata As String) As Boolean
Dim keyhand As Long
Dim r As Long
r = RegCreateKey(Hkey, strPath, keyhand)
r = RegSetValueEx(keyhand, strValue, 0, _
REG_SZ, ByVal strdata, Len(strdata))
r = RegCloseKey(keyhand)
SaveString = (r = 0)
End Function
- Pada Form yang aktif tambahkan 2 Textbox dan 1 CommandButton.
- Atur Properties Textboxt masing-masing dengan Name=txtOwner, Name=txtOrg dan Text=Dikosongkan saja.
- Atur Properties CommandButton dengan Name=cmdS dan Caption=Save.
- Setelah itu double click CommandButton dan di bawah cmdS_Click copy paste source code di bawah ini.
If Me.txtOwner.Text <> "" Or Me.txtOrg.Text <> "" Then
Call ChangeWindowsOwner(Me.txtOwner.Text, Me.txtOrg.Text)
Else
MsgBox "Owner Name and Organization Name not be empty.", vbExclamation, "Warning"
End If - Coba jalankan (F5) dan lihat hasilnya. Selesai.