ModRegData




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

---###--- Form ---###---
Inserisci un CommandButton in un Form, ad esempio chiamandoli rispettivamente cmdPulsante1 e frmPrincipale1 e inserisci in quel form il seguente codice:
Private Sub Command1_Click()
'Compare una dialog box in cui e' richiesto di inserire

'il nuovo nome della societa' da registrare

strOrg$ = InputBox("Societa':")
If strOrg$ = "" Then
MsgBox "Il nome della societa' non puo' essere vuoto", _
vbCritical, "Error"
Exit Sub
End If
'Salva la stringa (Societa') nel registry

Call savestring(HKEY_LOCAL_MACHINE, _
"Software\Microsoft\Windows\CurrentVersion", _
"RegisteredOrganization", strOrg$)
'Compare una dialog box in cui e' richiesto di inserire

'il nuovo nome del proprietaro da registrare

strOwner$ = InputBox("Proprietario:")
If strOwner$ = "" Then
MsgBox "Il nome del proprietario non puo' essere vuoto", _
vbCritical, "Error"
Exit Sub
End If
'Salva la stringa (Proprietario) nel registry

Call savestring(HKEY_LOCAL_MACHINE, _
"Software\Microsoft\Windows\CurrentVersion", _
"RegisteredOwner", strOwner$)
End Sub

'Per vedere i risultati di questa modifica, aprite il

'Pannello di Controllo, fate doppio clic sull'icona Sistema

'e date un'occhiata alle informazioni che compaiono nel tab

'Generale.











( modregdata.html )- by Paolo Puglisi - Modifica del 17/12/2023