首页 /编程语言和算法/VB6/ASP
 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


 
全部回复(0)
首页 | 电脑版 |