是否可以使用stdio函数读取Windows应用商店应用程序中的资产
Is it possible to read assets in Windows Store app using stdio functions?
我正在将一个用标准C++编写的现有应用程序移植到Windows8。我尝试过使用WRL来读取资产,但它很大,不适合我使用的多线程模型。C stdio函数似乎在开发机器上也能工作,但在将应用程序发布到Windows应用商店后,它们还会工作吗?
下面的代码获得文件系统上资产的完整路径,并使用它打开file:
auto uri = ref new Windows::Foundation::Uri("ms-appx:///Assets/Logo.png");
concurrency::create_task(Windows::Storage::StorageFile::GetFileFromApplicationUriAsync(uri))
.then([](Windows::Storage::StorageFile^ file)
{
FILE* f;
auto path = file->Path->Data();
auto e = _wfopen_s(&f, path, L"rb");
});
Windows应用商店应用程序将始终具有对其安装目录的读取访问权限和对其本地数据目录的读取/写入访问权限。即使在将应用程序发布到商店后,也可以使用stdio函数访问这些位置的文件。
需要清单文件中的条目才能访问的已知文件夹,如文档库,无法使用stdio访问。
应用程序的安装和本地数据文件夹是:
Windows::ApplicationModel::Package::Current->InstalledLocation
Windows::Storage::ApplicationData::Current->LocalFolder
获取文件系统路径并在安装位置打开资产文件的示例:
std::wstring wpath = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
wpath += L"\Assets\Logo.png";
FILE* f = nullptr;
errno_t e = _wfopen_s(&f, wpath.c_str(), L"rb");
Windows Phone应用程序的stdio也可以访问这些位置。Windows应用商店应用程序还可以使用stdio访问RoamingFolder和TemporaryFolder,这对Windows Phone应用程序不可用。更多信息可以在MSDN上找到:
http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.package.installedlocation.aspxhttp://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.aspx
相关文章:
- 试图在visual studio上用C++创建一个桌面应用程序
- FFmpeg:制作一个应用程序比直接使用ffmepg更好吗
- 在C应用程序中运行C++(带有STL)函数
- 使用VerQueryValue检索应用程序的文件描述
- Qt C++静态thread_local QNetworkAccessManager是线程应用程序的好选择吗
- 使用调试/崩溃报告将应用程序部署到客户端
- C++控制台应用程序阻止退出
- 码头化的C++应用程序是否向后兼容早期的内核版本
- 将应用程序从32位移植到64位时出现问题
- 如何改变c++应用程序的视觉效果
- WM_CTLCOLORSTATIC从未在WIN32应用程序中触发
- PC中的程序和PHONE中的本机描述应用程序之间的数据连接
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 示例外壳应用程序显示的 V8 "segmentation fault (core dumped)"错误
- phytec phyBOARD iMX-6在从闪存而不是SD卡运行qt5 opengles应用程序时表现不佳(FPS减半
- 为什么导入Mixed native/CLR lib.dll的本机C++应用程序没有在Mixed lib.dll中的外部变
- 如何从Windows应用程序输出到标准?
- C++应用程序 MySQL odbc 数据库连接错误:在引发"otl_tmpl_exception<>"实例后终止调用
- 如何在 64 位 vb.net Windows 应用程序中引用 32 位 dll
- 如何从Windows Service主函数启动c++本地应用程序(应用程序与控制台交互)?