Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" __
(ByVal nBufferLength As Long, ByVal lpBuffer As String) As Longprivate function MyTempPath() as string
  Dim sT As String
  Dim tmp As String
  Dim X As Integer  tmp = String$(2048, 32)
  X = GetTempPath(255, tmp)
  sT = Mid$(tmp, 1, X)
  If Right(sT, 1) = "\" Then sT = Left(sT, Len(sT) - 1)
  myTempPath = sT
end sub

解决方案 »

  1.   

    Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" __
    (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Longprivate function MyTempPath() as string
      Dim sT As String
      Dim tmp As String
      Dim X As Integer  tmp = String$(2048, 32)
      X = GetTempPath(255, tmp)
      sT = Mid$(tmp, 1, X)
      If Right(sT, 1) = "\" Then sT = Left(sT, Len(sT) - 1)
      myTempPath = sT
    end sub
      

  2.   

    直接用API函数嘛,我发现你们这些VB高手好象对API不是很感冒一样?WHY????
      

  3.   

    获得Temp目录:Declare Function GetTempPath Lib "KERNEL32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As LongPublic Function GetWindowTempPath() As String
           Dim Dummy As Long, StrLen As Long, TempPath As String
           StrLen = 255
           TempPath = String$(StrLen, 0)
           Dummy = GetTempPath(StrLen, TempPath)
           If Dummy Then
              GetWindowTempPath = Left$(TempPath, Dummy)
           Else
              GetWindowTempPath = ""
           End If
    End Function获得Windows目录:Declare Function GetWindowsDirectory Lib "KERNEL32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As LongPublic Function GetWindowsPath() As String
           Dim Dummy As Long, StrLen As Long, TempPath As String
           StrLen = 255
           TempPath = String$(StrLen, 0)
           Dummy = GetWindowsDirectory(TempPath, StrLen)
           If Dummy Then
              GetWindowsPath = Left$(TempPath, Dummy)
           Else
              GetWindowsPath = ""
           End If
    End Function当然,你还可以用iShellLinkA获得所有有关Windows的路径和目录。To lysccd: 他是VB高手吗???
      

  4.   

    用GetWindowsDirectory函数,
    返回的字符串+“\temp”就可以了。