I need to create a UNIQUE temp file name, one that does not exist in the temp directory.
I recently ran into a piece of code that was a work of art, but I thought that i could perhaps shorten it down by about 12 to 15 lines of code by using Windows to do the work for me
Please note!!! Windows will NOT clean this file up, it is your responsibility to do so.
When the API is complete a zero byte file will exist, closed, ready for your use.
------------------
Scott
mailto:[email protected][email protected]</A>
I recently ran into a piece of code that was a work of art, but I thought that i could perhaps shorten it down by about 12 to 15 lines of code by using Windows to do the work for me
Please note!!! Windows will NOT clean this file up, it is your responsibility to do so.
When the API is complete a zero byte file will exist, closed, ready for your use.
Code:
#Compile Exe #Include "win32api.inc" Declare Function GetNewTempFile()As String Declare Function GetWindowsTempDir() As String Function PbMain() As Long MsgBox GetNewTempFile End Function '======================================================================================== Function GetNewTempFile() Export As String Local lpszPath As Asciiz * %MAX_PATH Local lpTempFileName As Asciiz * 120 Local lpszPrefix As Asciiz * 20 Local r As Long lpszPrefix = "CCS" r = GetTempFileName(GetWindowsTempDir, lpszPrefix, 0, lpTempFileName) Function = lpTempFileName End Function '======================================================================================== Function GetWindowsTempDir()Export As String 'SPT 1/22/01 Local lResult As Long Local buff As Asciiz * 255 lResult = GetTempPath(ByVal SizeOf(buff), Buff) Function = Trim$(buff) End Function '========================================================================================
Scott
mailto:[email protected][email protected]</A>
Comment