practice8_10.frm
来自「深圳大学的vb上机与教学的课件」· FRM 代码 · 共 72 行
FRM
72 行
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 2175
ClientLeft = 60
ClientTop = 345
ClientWidth = 3405
LinkTopic = "Form1"
ScaleHeight = 2175
ScaleWidth = 3405
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command2
Caption = "获得计算机名"
Height = 375
Left = 240
TabIndex = 3
Top = 1560
Width = 2775
End
Begin VB.CommandButton Command1
Caption = "设置计算机名"
Height = 375
Left = 240
TabIndex = 1
Top = 960
Width = 2775
End
Begin VB.TextBox Text1
Height = 375
Left = 1320
TabIndex = 0
Top = 360
Width = 1695
End
Begin VB.Label Label1
Caption = "新计算机名:"
Height = 255
Left = 240
TabIndex = 2
Top = 480
Width = 1095
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'声明函数/过程
Private Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Command1_Click()
Dim myComputerName As String
If Text1.Text = "" Then
MsgBox ("计算机名不能为空!")
Else
myComputerName = Trim(Text1.Text)
result = SetComputerName(myComputerName)
'Print result
End If
End Sub
Private Sub Command2_Click()
Dim mysize As Long
Dim mybuffer As String
mysize = 255
mybuffer = Space(mysize)
Call GetComputerName(mybuffer, mysize)
Text1.Text = mybuffer
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?