Microsoft KB Archive/297802

= How To Find the Path to a Temporary Folder in Windows CE =

Article ID: 297802

Article Last Modified on 10/11/2004

-

APPLIES TO


 * Microsoft Windows CE 2.12 for the Handheld PC
 * Microsoft Windows CE 2.11 for the Handheld PC
 * Microsoft Windows CE 3.0 for the Handheld PC

-



This article was previously published under Q297802



SUMMARY
The GetTempPath API call provides the path of the directory designated for temporary files. Information about GetTempPath is not currently included in the Windows CE product documentation. This article provides the information needed to use GetTempPath.



MORE INFORMATION
The call has the following signature: DWORD GetTempPath(/*[in]*/ DWORD cchBufferLength, /*[out]*/ LPTSTR lpBuffer);

The parameters are as follows:
 * cchBufferLength - The length, in characters, of the buffer pointed to by lpBuffer.
 * lpBuffer - The pointer to a string buffer that will hold the returned path to the temporary folder.

The return value will be one of the following:
 * If the return value is less than or equal to the value passed in the cchBufferLength parameter, it specifies the number of characters returned in the lpBuffer parameter, not counting the NULL terminator.
 * If the return value is greater than the value passed in the cchBufferLength parameter, it specifies the number of characters needed in the lpBuffer parameter. This count of characters includes the NULL terminator.

The following sample demonstrates the use of GetTempPath: void CGetMyTempPath::OnGetTempPath {   _TCHAR  tszTempPath[MAX_PATH + 1]; DWORD  cchTempPath = sizeof(tszTempPath)/sizeof(_TCHAR); _TCHAR tszPathLength[100]; DWORD  cchPathLength; cchPathLength = ::GetTempPath(cchTempPath, tszTempPath); if(cchPathLength > cchTempPath) {       AfxMessageBox(_T(&quot;Temp path buffer is too small.&quot;)); }   else {       _stprintf(tszPathLength, _T(&quot;Length of the path is %d&quot;), cchPathLength); AfxMessageBox(tszTempPath); AfxMessageBox(tszPathLength); } }

Keywords: kbhowto KB297802

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.