【VB开源代码栏目提醒】:网学会员鉴于大家对VB开源代码十分关注,论文会员在此为大家搜集整理了“frmComputerName.frm”一文,供大家参考学习
VERSION 5.00
Begin VB.Form frmComputerName
BorderStyle = 1 'Fixed Single
Caption = "Computer Name"
ClientHeight = 3795
ClientLeft = 45
ClientTop = 330
ClientWidth = 5295
Icon = "frmComputerName.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3795
ScaleWidth = 5295
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox txtPhysicalDNSFullyQualified
Appearance = 0 'Flat
BackColor = &H8000000F&
BorderStyle = 0 'None
Height = 285
Left = 2520
Locked = -1 'True
TabIndex = 17
Top = 3000
Width = 2655
End
Begin VB.TextBox txtPhysicalDNSDomain
Height = 285
Left = 2520
TabIndex = 15
Top = 2640
Width = 2655
End
Begin VB.TextBox txtPhysicalDNSHostname
Height = 285
Left = 2520
TabIndex = 13
Top = 2280
Width = 2655
End
Begin VB.TextBox txtPhysicalNetBIOS
Height = 285
Left = 2520
TabIndex = 11
Top = 1920
Width = 2655
End
Begin VB.TextBox txtDNSFullyQualified
Appearance = 0 'Flat
BackColor = &H8000000F&
BorderStyle = 0 'None
Height = 285
Left = 2520
Locked = -1 'True
TabIndex = 9
Top = 1560
Width = 2655
End
Begin VB.TextBox txtDNSDomain
Appearance = 0 'Flat
BackColor = &H8000000F&
BorderStyle = 0 'None
Height = 285
Left = 2520
Locked = -1 'True
TabIndex = 7
Top = 1200
Width = 2655
End
Begin VB.TextBox txtDNSHostname
Appearance = 0 'Flat
BackColor = &H8000000F&
BorderStyle = 0 'None
Height = 285
Left = 2520
Locked = -1 'True
TabIndex = 5
Top = 840
Width = 2655
End
Begin VB.TextBox txtNetBIOS
Appearance = 0 'Flat
BackColor = &H8000000F&
BorderStyle = 0 'None
Height = 285
Left = 2520
Locked = -1 'True
TabIndex = 3
Top = 480
Width = 2655
End
Begin VB.TextBox txtComputerName
Height = 285
Left = 2520
TabIndex = 1
Top = 120
Width = 2655
End
Begin VB.CommandButton cmdApply
Caption = "Apply"
Height = 350
Left = 4200
TabIndex = 18
Top = 3360
Width = 975
End
Begin VB.Label lblPhysicalDNSFullyQualified
Caption = "Physical DNS Fully Qualified"
Height = 495
Left = 120
TabIndex = 16
Top = 3000
Width = 2175
End
Begin VB.Label lblPhysicalDNSDomain
Caption = "Physical DNS Domain"
Height = 255
Left = 120
TabIndex = 14
Top = 2640
Width = 2175
End
Begin
VB.Label lblPhysicalDNSHostname
Caption = "Physical DNS Hostname"
Height = 255
Left = 120
TabIndex = 12
Top = 2280
Width = 2175
End
Begin VB.Label lblPhysicalNetBIOS
Caption = "Physical Net BIOS"
Height = 255
Left = 120
TabIndex = 10
Top = 1920
Width = 2175
End
Begin VB.Label lblDNSFullyQualified
Caption = "DNS Fully Qualified"
Height = 255
Left = 120
TabIndex = 8
Top = 1560
Width = 2175
End
Begin VB.Label lblDNSDomain
Caption = "DNS Domain"
Height = 255
Left = 120
TabIndex = 6
Top = 1200
Width = 2175
End
Begin VB.Label lblDNSHostname
Caption = "DNS Hostname"
Height = 255
Left = 120
TabIndex = 4
Top = 840
Width = 2175
End
Begin VB.Label lblNetBIOS
Caption = "Net BIOS"
Height = 255
Left = 120
TabIndex = 2
Top = 480
Width = 2175
End
Begin VB.Label lblComputerName
Caption = "Computer Name"
Height = 255
Left = 120
TabIndex = 0
Top = 120
Width = 2175
End
End
Attribute VB_Name = "frmComputerName"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const sLocation As String = "frmComputerName"
Private Sub cmdApply_Click()
On Error GoTo VB_Error
txtComputerName.Text = Rem_NonStd_Chr(txtComputerName.Text)
If Len(txtComputerName.Text) > MAX_COMPUTERNAME_LENGTH Then
txtComputerName.Text = Left$(txtComputerName.Text, MAX_COMPUTERNAME_LENGTH)
End If
If SetComputerName(txtComputerName.Text) = False Then Call Error_API(Err.LastDllError, sLocation & "\cmdApply_Click", "SetComputerName")
If WinVersion(-1, 5000000, True) = True Then
txtPhysicalNetBIOS.Text = Rem_NonStd_Chr(txtPhysicalNetBIOS.Text)
If Len(txtPhysicalNetBIOS.Text) > MAX_COMPUTERNAME_LENGTH Then
txtPhysicalNetBIOS.Text = Left$(txtPhysicalNetBIOS.Text, MAX_COMPUTERNAME_LENGTH)
End If
txtPhysicalDNSHostname.Text = Rem_NonStd_Chr(txtPhysicalDNSHostname.Text)
txtPhysicalDNSDomain.Text = Rem_NonStd_Chr(txtPhysicalDNSDomain.Text)
If SetComputerNameEx(ComputerNamePhysicalNetBIOS, txtPhysicalNetBIOS.Text) = False Then Call Error_API(Err.LastDllError, sLocation & "\cmdApply_Click", "SetComputerNameEx")
If SetComputerNameEx(ComputerNamePhysicalDnsHostname, txtPhysicalDNSHostname.Text) = False Then Call Error_API(Err.LastDllError, sLocation & "\cmdApply_Click", "SetComputerNameEx")
If SetComputerNameEx(ComputerNamePhysicalDnsDomain, txtPhysicalDNSDomain.Text) = False Then Call Erro