Zm∞na registrace Windows

Postup:
Zalo₧te nov² projekt. Vlo₧te nov² modul. Do modulu deklarujte:

Public Const HKEY_LOCAL_MACHINE = &H80000002

Declare Function RegCreateKey Lib _
"advapi32.dll" Alias "RegCreateKeyA" _
(ByVal Hkey As Long, ByVal lpSubKey As _
String, phkResult As Long) As Long

Declare Function RegCloseKey Lib _
"advapi32.dll" (ByVal Hkey 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, lpData As Any, ByVal _
cbData As Long) As Long

Public Const REG_SZ = 1
Public Const REG_DWORD = 4

Public Sub savestring(Hkey As Long, strPath As String, _
strValue As String, strdata As String)

   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)
End Sub

Na formulß° p°idejte tlaΦφtko Command1 a na jeho udßlost Click:

Private Sub Command1_Click() 

   'Dotaz na novΘ jmΘno registrovanΘ organizace
   strOrganization$ = InputBox("Organisation:") 
   If strOrganization$ = "" Then 
      MsgBox "Empty String", vbCritical, "Error" 
      Exit Sub 
   End If 
   'Ulo₧enφ do registru 
   Call savestring(HKEY_LOCAL_MACHINE, _    "Software\Microsoft\Windows\CurrentVersion", _    "RegisteredOrganization", strOrganization$) 
   'Dotaz na novΘho vlastnφka
   strOwner$ = InputBox("Owner:") 
   If strOwner$ = "" Then 
      MsgBox "Empty String", vbCritical, "Error" 
      Exit Sub 
   End If 
   'Ulo₧enφ do registru 
   Call savestring(HKEY_LOCAL_MACHINE, _    "Software\Microsoft\Windows\CurrentVersion", _    "RegisteredOwner", strOwner$) 

End Sub

Spus¥te projekt. Pokud vÜe prob∞hne v po°ßdku, zm∞nφ se organizace a u₧ivatel. Ov∞°it si to m∙₧ete v Ovlßdacφch panelech/SystΘm/ObecnΘ.

Zp∞t

Autor: The Bozena