查看: 5  |  回复: 0
  VB6 利用API的GetWindowsDirectory和GetSystemDirectory得到系统目录
楼主
发表于 今天 17:34

新建From1(窗体),代码:

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

Private Sub Form_Load()
    Dim S As String * 80, Length As Long
    Dim WinPath As String, SysPath As String
    Length = GetWindowsDirectory(S, Len(S))
    WinPath = Left(S, Length)
    Length = GetSystemDirectory(S, Len(S))
    SysPath = Left(S, Length)
    Debug.Print SysPath
End Sub

运行结果:

C:\Windows\system32


您需要登录后才可以回帖 登录 | 立即注册
【本版规则】请勿发表违反国家法律的内容,否则会被冻结账号和删贴。
用户名: 立即注册
密码:
2020-2024 MaNongKu.com