fb:porticula NoPaste
Temporäre Dateien in FreeBASIC nutzen (Win.)
Uploader: | Sebastian |
Datum/Zeit: | 31.05.2008 21:52:01 |
Declare Function GetTempPath Lib "kernel32" Alias _
"GetTempPathA" (ByVal nBufferLength As Integer, ByVal _
lpBuffer As ZString Ptr) As Long
Declare Function GetTempFileName Lib "kernel32" _
Alias "GetTempFileNameA" (ByVal lpszPath As ZString Ptr, _
ByVal lpPrefixString As ZString Ptr, ByVal wUnique As _
Integer, ByVal lpTempFileName As ZString Ptr) As Integer
Function TempDir () As String
Dim As String*255 TempPath, Alt
If GetTempPath (255,STRPTR(TempPath)) <> 0 Then
Return Trim(TempPath)
Else
Alt = ENVIRON("TEMP")
If Alt = "" Then Alt = ENVIRON("TMP")
IF Alt = "" Then Alt = ENVIRON("TEMP")
Return Alt
END IF
END FUNCTION
Function TempFile () As String
Dim As String TempPath
Dim As String*255 Buffer
Dim As Integer Result
TempPath = TempDir()
Result = GetTempFileName(TempPath,STRPTR("~FB"),0,STRPTR(Buffer))
If Result = 0 Then
RETURN ""
ELSe
RETURN TRIM(Buffer)
END IF
END FUNCTION
PRINT
PRINT " Tempor"; CHR(132); "re Dateien"
PRINT
PRINT " Verzeichnis f"; CHR(129); "r temp. Dateien: ";
COLOR 14
PRINT TempDir()
COLOR 7
PRINT " Zu nutzende temp. Datei: ";
COLOR 14
PRINT TempFile()
COLOR 7
SLEEP