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

📄 form1.frm

📁 本文件包含200个visual baisc实例
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "获得windows和system路径"
   ClientHeight    =   2745
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6465
   LinkTopic       =   "Form1"
   ScaleHeight     =   2745
   ScaleWidth      =   6465
   StartUpPosition =   1  '所有者中心
   Begin VB.CommandButton Command1 
      Caption         =   "退出"
      Height          =   465
      Left            =   1890
      TabIndex        =   0
      Top             =   2070
      Width           =   2685
   End
   Begin VB.Label Label2 
      Height          =   450
      Left            =   1275
      TabIndex        =   2
      Top             =   1245
      Width           =   4215
   End
   Begin VB.Label Label1 
      Height          =   450
      Left            =   1275
      TabIndex        =   1
      Top             =   450
      Width           =   4215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" _
    (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" _
    (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Private Const max_path = 260
Private Const max_path1 = 261

Private Sub Form_Activate()
  Dim sysdir As String
  Dim chrlen As Long
  Dim windir As String
  
' 获得system路径
  sysdir = Space(max_path)
  chrlen = GetSystemDirectory(sysdir, max_path)
  If chrlen > max_path Then chrlen = GetSystemDirectory(sysdir, chrlen)
  sysdir = Left(sysdir, chrlen)
' 获得windows路径
  windir = Space(max_path)
  chrlen = GetWindowsDirectory(windir, max_path)
  If chrlen > max_path Then chrlen = GetWindowsDirectory(windir, chrlen)
  windir = Left(windir, chrlen)
  
' 在窗体上显示system路径
  Label1.Caption = "system的路径为: " & sysdir
' 在窗体上显示windows路径
  Label2.Caption = "windows的路径为: " & windir
End Sub

Private Sub Command1_Click()
  End
End Sub

⌨️ 快捷键说明

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