Warung Bebas

Kamis, 20 Juni 2013

Ganti Owner Name dan Organization pada Windows dengan VB 6.0

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).
  1. Buka VB 6.0 dan buat Project baru.
  2. 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
  3. Pada Form yang aktif tambahkan 2 Textbox dan 1 CommandButton.
  4. Atur Properties Textboxt masing-masing dengan Name=txtOwner, Name=txtOrg dan Text=Dikosongkan saja.
  5. Atur Properties CommandButton dengan Name=cmdS dan Caption=Save.
  6. 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
  7. Coba jalankan (F5) dan lihat hasilnya. Selesai.
Silakan download full source code program dari tombol di bawah ini.

0 komentar em “Ganti Owner Name dan Organization pada Windows dengan VB 6.0”

Posting Komentar

 

Indah Hidup Copyright © 2012 Fast Loading -- Powered by Blogger