读注册表,得到%ProgramFiles%,但是希望得到具体路径,该怎么做?

解决方案 »

  1.   

    Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As LongPrivate Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As LongPrivate Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As LongPrivate Sub Form_Load()
    Dim s As String * 80
    Dim TempPath As String
    Dim Length As Long
    Dim Winpath As String
    Dim Syspath As String
    Length = GetWindowsDirectory(s, Len(s))
    Winpath = Left(s, Length)
    Length = GetSystemDirectory(s, Len(s))
    Syspath = Left(s, Length)
    Length = GetTempPath(Len(s), s)
    TempPath = Left(s, length)MsgBox "WIN目录:" & Winpath & Chr(13) & Chr(10) & "系统目录:" & Syspath & Chr(13) & Chr(10)  & "Temp目录:" & TempPathEndEnd Sub