⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 大量优秀的vb编程
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3048
   ClientLeft      =   48
   ClientTop       =   348
   ClientWidth     =   4152
   LinkTopic       =   "Form1"
   ScaleHeight     =   3048
   ScaleWidth      =   4152
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command2 
      Caption         =   "设置计算机名称"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   732
      Left            =   1320
      TabIndex        =   2
      Top             =   1800
      Width           =   1212
   End
   Begin VB.TextBox Text1 
      Height          =   492
      Left            =   1200
      TabIndex        =   1
      Top             =   1080
      Width           =   1572
   End
   Begin VB.CommandButton Command1 
      Caption         =   "获得计算机名称"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   732
      Left            =   1320
      TabIndex        =   0
      Top             =   120
      Width           =   1092
   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 GetComputerName Lib "kernel32" Alias _
    "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function SetComputerName Lib "kernel32" Alias _
    "SetComputerNameA" (ByVal lpComputerName As String) As Long
    

Private Sub Command1_Click()
    Dim Name1 As String * 255
    Dim name As String
    Dim i As Integer
    
    i = GetComputerName(Name1, 255)
    
    If i <> 0 Then
        name = Name1
    Else
        name = "unknown"
    End If
    
    Text1 = name
    
End Sub

Private Sub Command2_Click()
    Dim i As Integer
    Dim name As String
    
    name = Text1.Text
    
    i = SetComputerName(name)
    If i = 0 Then
        MsgBox "fail!", vbOKOnly
    Else
        MsgBox "success!", vbOKOnly
    End If
    
        
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -