home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Profession19234552001.psc / basCommon.bas < prev    next >
Encoding:
BASIC Source File  |  2001-05-01  |  1.4 KB  |  32 lines

  1. Attribute VB_Name = "basCommon"
  2. Declare Function GetTempFilename32 Lib "kernel32" Alias "GetTempFileNameA" (ByVal strWhichDrive As String, ByVal lpPrefixString As String, ByVal wUnique As Integer, ByVal lpTempFilename As String) As Long
  3. Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
  4.  
  5. Function GetTempFilename(ByVal strDestPath As String, ByVal lpPrefixString As String, ByVal wUnique As Integer, lpTempFilename As String) As Boolean
  6.     If strDestPath = vbNullString Then
  7.         '
  8.         ' No destination was specified, use the temp directory.
  9.         '
  10.         strDestPath = String(gintMAX_PATH_LEN, vbNullChar)
  11.         If GetTempPath(gintMAX_PATH_LEN, strDestPath) = 0 Then
  12.             GetTempFilename = False
  13.             Exit Function
  14.         End If
  15.     End If
  16.     lpTempFilename = String(gintMAX_PATH_LEN, vbNullChar)
  17.     GetTempFilename = GetTempFilename32(strDestPath, lpPrefixString, wUnique, lpTempFilename) > 0
  18.     lpTempFilename = StripTerminator(lpTempFilename)
  19. End Function
  20.  
  21. Function StripTerminator(ByVal strString As String) As String
  22.     Dim intZeroPos As Integer
  23.  
  24.     intZeroPos = InStr(strString, Chr$(0))
  25.     If intZeroPos > 0 Then
  26.         StripTerminator = Left$(strString, intZeroPos - 1)
  27.     Else
  28.         StripTerminator = strString
  29.     End If
  30. End Function
  31.  
  32.