How To Find the Path to a Temporary Folder in Windows CE (297802)



The information in this article applies to:

  • Microsoft Windows CE Operating System, Versions 2.12
  • Microsoft Windows CE Operating System, Versions 2.11
  • Microsoft Windows CE Operating System, Versions 3.0

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("Temp path buffer is too small."));
	}
	else
	{
		_stprintf(tszPathLength, _T("Length of the path is %d"), cchPathLength); 
		AfxMessageBox(tszTempPath);
		AfxMessageBox(tszPathLength);
	}
}
				

Modification Type:MinorLast Reviewed:10/11/2004
Keywords:kbhowto KB297802