Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long
设置新的计算机名
Long,非零表示成功,零表示失败。会设置GetLastErrorlpComputerName - String,新的计算机名称。最多可有MAX_COMPUTERNAME_LENGTH个字符windows95会将任何非法字符自动转换到标准的字符集里。windows
nt则会报告出错
'SetComputerName
Private Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long
Private Sub Form_Load()
'KPD-Team 1999
'E-Mail: [email protected]
Dim sNewName As String
'Ask for a new computer name
sNewName = InputBox("Please enter a new computer name.")
'Set the new computer name
SetComputerName sNewName
MsgBox "Computername set to " + sNewName
End Sub
设置新的计算机名
Long,非零表示成功,零表示失败。会设置GetLastErrorlpComputerName - String,新的计算机名称。最多可有MAX_COMPUTERNAME_LENGTH个字符windows95会将任何非法字符自动转换到标准的字符集里。windows
nt则会报告出错
'SetComputerName
Private Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long
Private Sub Form_Load()
'KPD-Team 1999
'E-Mail: [email protected]
Dim sNewName As String
'Ask for a new computer name
sNewName = InputBox("Please enter a new computer name.")
'Set the new computer name
SetComputerName sNewName
MsgBox "Computername set to " + sNewName
End Sub
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ComputerName]
"ComputerName"="MyPc"