Skip to content

Latest commit

 

History

History
202 lines (156 loc) · 5.55 KB

nf-fileapi-gettemppathw.md

File metadata and controls

202 lines (156 loc) · 5.55 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:fileapi.GetTempPathW
GetTempPathW function (fileapi.h)
Retrieves the path of the directory designated for temporary files. (Unicode)
GetTempPath
GetTempPath function [Files]
GetTempPathW
_win32_gettemppath
base.gettemppath
fileapi/GetTempPath
fileapi/GetTempPathW
fs.gettemppath
fs\gettemppath.htm
fs
fb366f0d-df6b-44c2-92c9-b7a8e2583054
12/05/2018
GetTempPath, GetTempPath function [Files], GetTempPathA, GetTempPathW, _win32_gettemppath, base.gettemppath, fileapi/GetTempPath, fileapi/GetTempPathA, fileapi/GetTempPathW, fs.gettemppath, winbase/GetTempPath, winbase/GetTempPathA, winbase/GetTempPathW
fileapi.h
Windows.h
Windows
Windows XP [desktop apps \| UWP apps]
Windows Server 2003 [desktop apps \| UWP apps]
GetTempPathW (Unicode) and GetTempPathA (ANSI)
Kernel32.lib
Kernel32.dll
Windows
19H1
GetTempPathW
fileapi/GetTempPathW
c++
APIRef
kbSyntax
DllExport
Kernel32.dll
API-MS-Win-Core-Kernel32-Legacy-l1-1-0.dll
kernel32legacy.dll
API-MS-Win-Core-Kernel32-Legacy-l1-1-1.dll
API-MS-Win-Core-Kernel32-Legacy-l1-1-2.dll
API-MS-Win-DownLevel-Kernel32-l2-1-0.dll
API-MS-Win-Core-File-l1-2-0.dll
KernelBase.dll
API-MS-Win-Core-File-l1-2-1.dll
API-MS-Win-Core-File-l1-2-2.dll
API-MS-Win-DownLevel-Kernel32-l1-1-0.dll
MinKernelBase.dll
API-MS-Win-Core-Kernel32-Legacy-L1-1-3.dll
API-MS-Win-Core-Kernel32-Legacy-L1-1-4.dll
API-MS-Win-Core-Kernel32-Legacy-L1-1-5.dll
GetTempPath
GetTempPathA
GetTempPathW

GetTempPathW function

-description

Retrieves the path of the directory designated for temporary files.

-parameters

-param nBufferLength [in]

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

-param lpBuffer [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

Note

Apps should call GetTempPath2 instead of GetTempPath.

The GetTempPath 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 GetTempPath 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 GetTempPath 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