The GetTempFileName function creates a name for a temporary file. The filename is the concatenation of specified path and prefix strings, a hexadecimal string formed from a specified integer, and the .TMP extension.
The specified integer can be nonzero, in which case, the function creates the filename but does not create the file. If you specify zero for the integer, the function creates a unique filename and creates the file in the specified directory.
UINT GetTempFileName(
LPCTSTR lpPathName, |
// address of directory name for temporary file |
LPCTSTR lpPrefixString, |
// address of filename prefix |
UINT uUnique, |
// number used to create temporary filename |
LPTSTR lpTempFileName |
// address of buffer that receives the new filename |
); |
If uUnique is nonzero, the function appends the hexadecimal string to lpPrefixString to form the temporary filename. In this case, the function does not create the specified file, and does not test whether the filename is unique.
If uUnique is zero, the function uses a hexadecimal string derived from
the current system time. In this case, the function uses different values
until it finds a unique filename, and then it creates the file in the lpPathName
directory.
If the function succeeds, the return value specifies the unique numeric value used in the temporary filename. If the uUnique parameter is nonzero, the return value specifies that same number.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
The GetTempFileName function creates a temporary filename of the following form:
path\preuuuu.TMP
The following table describes the filename syntax:
Component |
Meaning |
path |
Path specified by the lpPathName parameter |
pre |
First three letters of the lpPrefixString string |
uuuu |
Hexadecimal value of uUnique |
When Windows shuts down, temporary files whose names have been created by this function are not automatically deleted.
To avoid problems resulting from converting an ANSI character set string to a Windows string, an application should call the CreateFile function to create a temporary file.
If the uUnique parameter is zero, GetTempFileName attempts to form a unique number based on the current system time. If a file with the resulting filename exists, the number is increased by one and the test for existence is repeated. Testing continues until a unique filename is found. GetTempFileName then creates a file by that name and closes it. When uUnique is nonzero, no attempt is made to create and open the file.
file: /Techref/os/win/api/win32/func/src/f40_15.htm, 6KB, , updated: 2000/4/7 11:19, local time: 2024/11/28 03:01,
3.145.75.238:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.org/techref/os/win/api/win32/func/src/f40_15.htm"> GetTempFileName</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.