比如:c:\windows

解决方案 »

  1.   

    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 Sub Command1_Click() 
     Dim SystemPath As String * 1000, WindowPath As String * 1000 
     Call GetSystemDirectory(SystemPath, 1000) 
     SystemPath = Left$(SystemPath, InStr(SystemPath, Chr$(0))) '一般得到C:\WINDOWS\System32 
     Call GetWindowsDirectory(WindowPath, 1000) 
     WindowPath = Left$(WindowPath, InStr(WindowPath, Chr$(0))) '一般得到C:\WINDOWS 
    End Sub
      

  2.   

    GetSystemDirectory() API
    或者
    FSO里面的GetSpecialFolder,参考 http://msdn.microsoft.com/en-us/library/a72y2t1c(VS.85).aspx