VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 如何改变注册组和成员的名称
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:8103, 日期:2001-04-25
How to change the name of the Registered Organization and Owner

This tip demonstrates how to change the Registered Owner and organisation by altering a value in the registry.

Declarations

Add the following code to a module.

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 SubForm

Put a Commandbutton1 on form1 and add the following code:

Private Sub Command1_Click()

注释:Prompts for the new name of the Registered Organization
strOrganization$ = InputBox("Organisation:")
If strOrganization$ = "" Then
MsgBox "Empty String", vbCritical, "Error"
Exit Sub
End If

注释:Saves string (Organization) to the registry
Call savestring(HKEY_LOCAL_MACHINE, _
"Software\Microsoft\Windows\CurrentVersion", _
"RegisteredOrganization", strOrganization$)

注释:Prompts for the new name of the Registered Owner
strOwner$ = InputBox("Owner:")
If strOwner$ = "" Then
    MsgBox "Empty String", vbCritical, "Error"
    Exit Sub
End If

注释:Saves string (Owner) to the registry
Call savestring(HKEY_LOCAL_MACHINE, _
"Software\Microsoft\Windows\CurrentVersion", _
"RegisteredOwner", strOwner$)

End SubTo see the result go to Control Panel / System / General.

Tip by Gijs de Jong