Option ExplicitPrivate Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long Private Sub Form_Load() Dim strString As String 'Create a buffer strString = String(255, Chr$(0)) 'Get the computer name GetComputerName strString, 255 'remove the unnecessary chr$(0)'s strString = Left$(strString, InStr(1, strString, Chr$(0))) 'Show the computer name Text1.Text = strString End Sub
Private Sub Form_Load()
Dim strString As String
'Create a buffer
strString = String(255, Chr$(0))
'Get the computer name
GetComputerName strString, 255
'remove the unnecessary chr$(0)'s
strString = Left$(strString, InStr(1, strString, Chr$(0)))
'Show the computer name
Text1.Text = strString
End Sub
快捷键给定位 F3
Text1.SetFocus
'一个text,一个command
Private Sub Command1_Click()
Text1.Text = Environ("ComputerName")
End Sub
使用
registerhotkey
setwindowlong
callwindowproc
等api