次の方法で共有


GetTempPath (Compact 2013)

3/26/2014

This function obtains the path of the directory designated for temporary files.

Syntax

DWORD GetTempPath(
  DWORD ccBuffer, 
  LPTSTR lpszBuffer
); 

Parameters

  • ccBuffer
    [in] Length, in characters, of the string buffer specified by the lpszBuffer parameter.
  • lpszBuffer
    [out] Pointer to a string buffer that receives the null-terminated string specifying the temporary path. The retrieved string ends with a backslash (\).

Return Value

The length, in characters, of the string copied to lpszBuffer, not including the terminating NULL character, indicates success. If the return value is greater than the size of ccBuffer, the return value is the size of the buffer required to hold the path. Zero (0) indicates failure.

Remarks

The default path returned by GetTempPath is "\temp\". This default path can be changed by adding a registry key as shown in the following code example.

[HKEY_LOCAL_MACHINE\SYSTEM\FileSys]
    "TempPath"="\My\New\Temp\Path\"

In the example, \My\New\Temp\Path\ is a placeholder for a path to an existing directory on your system. The specified directory path must exist before any caller of GetTempPath uses the path; otherwise, GetTempPath returns 0 (zero) to indicate failure. Writing an application that creates the directory at startup is one way to make sure the directory specified in the path exists.

Requirements

Header

winbase.h

Library

coredll.lib

See Also

Reference

File I/O Functions

Other Resources

SHGetSpecialFolderLocation