Results 1 to 4 of 4

Thread: GetTmpPath

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Location
    Oporto - Portugal
    Posts
    16

    Talking

    Hi guys

    i´m using these API function to find dir \Temp\ in Windows NT

    [code]
    Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _
    (ByVal nbufferlength As Long, ByVal ipbuffer As String) As Long

    Public Const MAX_PATH = 260
    [code]

    [code]
    Public Function GetTmpPath()
    Dim strfolder As String
    Dim lngResult As String

    strfolder = String(MAX_PATH, 0)
    lngResult = GetTempPath(MAX_PATH, strfolder)

    If lngResult <> 0 Then
    GetTmpPath = Left(strfolder, InStr(strfolder, Chr(0), -1))
    Else
    GetTmpPath = ""
    End If
    End Function
    [code]


    When i click it occurs a run-time error 13 Type mismatch

    [code]
    Private Sub Command3_Click()
    Call MsgBox("O caminho da Temp " & GetTmpPath, 64+vbInformation)

    [code]

    Any Help

    Thanks

  2. #2
    Lively Member
    Join Date
    Mar 2000
    Posts
    81
    Why not make your own function that looks up the "Temp" and/or "Tmp" environment settings, as in (e.g., untested)

    Code:
    Public Function GetTemp() As String
    
    Dim s As String
    
    s = Environ("Temp")
    If Len(s) = 0 Then
         s = Environ("Tmp")
         If Len(s) = 0 Then
              ' error - no environ setting
              err.Raise 10001, "GetTemp", "No Temp Environment Setting found"
         End If
    End If
    
    GetTemp = s
    
    End Function
    HTH!

    Toot
    Some cause happiness wherever they go; others, whenever they go.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Location
    Oporto - Portugal
    Posts
    16
    Originally posted by Toot
    Why not make your own function that looks up the "Temp" and/or "Tmp" environment settings, as in (e.g., untested)

    Code:
    Public Function GetTemp() As String
    
    Dim s As String
    
    s = Environ("Temp")
    If Len(s) = 0 Then
         s = Environ("Tmp")
         If Len(s) = 0 Then
              ' error - no environ setting
              err.Raise 10001, "GetTemp", "No Temp Environment Setting found"
         End If
    End If
    
    GetTemp = s
    
    End Function
    HTH!

    Toot
    Thanks a lot TOOT it works

    Have u have e-mail?


  4. #4
    Lively Member
    Join Date
    Mar 2000
    Posts
    81

    Thumbs up

    Yup see below...
    Some cause happiness wherever they go; others, whenever they go.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width