简体   繁体   English

与Windows Phone上的GetTempPath等效

[英]Equivalent of the GetTempPath on Windows Phone

I am compiling a third party library libkml for Windows Universal App. 我正在为Windows Universal App编译第三方库libkml And I notice that the following Win32 API is not available on anything but WINAPI_PARTITION_DESKTOP . 而且我注意到以下Win32 API在WINAPI_PARTITION_DESKTOP上不可用。

The following is from fileapi.h : 以下是来自fileapi.h的内容

#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)

WINBASEAPI
DWORD
WINAPI
GetTempPathW(
    _In_ DWORD nBufferLength,
    _Out_writes_to_opt_(nBufferLength, return + 1) LPWSTR lpBuffer
    );
... 
#endif

Does anyone know the equivalent function for this GetTempPath for Windows Store App and Windows Phone App? 谁知道此GetTempPath for Windows Store App和Windows Phone App的等效功能吗?

Here is an example GetTemporaryDirectory() wrapper function taken from the following MSDN blog article about " Writing shared code for Windows Store and Win32 desktop apps ": 这是一个示例GetTemporaryDirectory()包装函数,该函数来自以下MSDN博客文章,内容涉及“ 为Windows Store和Win32桌面应用程序编写共享代码 ”:

Dual-use Coding Techniques for Games, part 3 . 游戏的双重用途编码技术,第3部分

void GetTemporaryDirectory( wchar_t* dir, size_t maxsize )
{
    if ( !maxsize ) return;
    *dir = 0;
    #if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
    DWORD nChars = GetTempPath( maxsize, dir );
    if ( nChars > 0 )
        dir[nChars-1] = '\0'; // Trim trialing '\'
    else
        *dir = 0;
    #else // Windows Store WinRT app
    auto folder = Windows::Storage::ApplicationData::Current->TemporaryFolder;
    wcscpy_s( dir, maxsize, folder->Path->Data() );
    #endif // WINAPI_FAMILY_PARTITION
} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM