Skip to content

Latest commit

 

History

History
184 lines (137 loc) · 4.8 KB

nf-fileapi-gettemppath2a.md

File metadata and controls

184 lines (137 loc) · 4.8 KB
UID title ms.date ms.topic targetos description helpviewer_keywords tech.root req.assembly req.construct-type req.ddi-compliance req.dll req.header req.idl req.include-header req.irql req.kmdf-ver req.lib req.max-support req.namespace req.redist req.target-min-winverclnt req.target-min-winversvr req.target-type req.type-library req.umdf-ver req.unicode-ansi topic_type api_type api_location api_name f1_keywords dev_langs
NF:fileapi.GetTempPath2A
GetTempPath2A
10/07/2020
language-reference
Windows
Retrieves the path of the directory designated for temporary files, based on the privileges of the calling process. (ANSI)
GetTempPath2A
GetTempPath2A
fileapi/GetTempPath2A
fs
function
Kernel32.dll
fileapi.h
Windows.h
Kernel32.lib
Windows 10 Build 20348
Windows Server Build 20348
GetTempPath2W (Unicode) and GetTempPath2A (ANSI)
apiref
DllExport
api-ms-win-core-file-l1-2-4.dll
kernel32.dll
kernelbase.dll
GetTempPath2A
GetTempPath2A
fileapi/GetTempPath2A
c++

-description

Retrieves the path of the directory designated for temporary files, based on the privileges of the calling process.

-parameters

-param BufferLength [in]

The size of the string buffer identified by lpBuffer, in TCHARs.

-param Buffer [out]

A pointer to a string buffer that receives the null-terminated string specifying the temporary file path. The returned string ends with a backslash, for example, "C:\TEMP\".

-returns

If the function succeeds, the return value is the length, in TCHARs, of the string copied to lpBuffer, not including the terminating null character. If the return value is greater than nBufferLength, the return value is the length, in TCHARs, of the buffer required to hold the path.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

The maximum possible return value is MAX_PATH+1 (261).

-remarks

When calling this function from a process running as SYSTEM it will return the path C:\Windows\SystemTemp, which is inaccessible to non-SYSTEM processes. For non-SYSTEM processes, GetTempPath2 will behave the same as GetTempPath.

The GetTempPath2 function checks for the existence of environment variables in the following order and uses the first path found:

  1. The path specified by the TMP environment variable.
  2. The path specified by the TEMP environment variable.
  3. The path specified by the USERPROFILE environment variable.
  4. The Windows directory.
Note that the function does not verify that the path exists, nor does it test to see if the current process has any kind of access rights to the path. The GetTempPath2 function returns the properly formatted string that specifies the fully qualified path based on the environment variable search order as previously specified. The application should verify the existence of the path and adequate access rights to the path prior to any use for file I/O operations.

Symbolic link behavior—If the path points to a symbolic link, the temp path name maintains any symbolic links.

In Windows 8 and Windows Server 2012, this function is supported by the following technologies.

Technology Supported
Server Message Block (SMB) 3.0 protocol Yes
SMB 3.0 Transparent Failover (TFO) Yes
SMB 3.0 with Scale-out File Shares (SO) Yes
Cluster Shared Volume File System (CsvFS) Yes
Resilient File System (ReFS) Yes
 

Examples

For an example, see Creating and Using a Temporary File.

Note

The fileapi.h header defines GetTempPath2 as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

-see-also

File Management Functions

GetTempFileName

Symbolic Links

-see-also