简体   繁体   English

使用Microsoft Desktop App Converter将Win32应用程序转换为UWP时,如何将文件保存到AppData?

[英]How to save files to AppData when using Microsoft Desktop App Converter to convert a Win32 app to UWP?

I have a game that was originally written in QuickBasic in the 1990's. 我的游戏最初是在1990年代用QuickBasic编写的。 I converted it into a Win32 app using QB64. 我使用QB64将其转换为Win32应用程序。 I then used Microsoft's Desktop App Converter to package it as a UWP app and submit it to the Microsoft Store (it's been accepted ). 然后我使用Microsoft的桌面应用程序转换器将其打包为UWP应用程序并将其提交到Microsoft Store(已被接受 )。

The game seems to work fine, except for saving files. 除了保存文件外,游戏似乎运行正常。 It throws a permission denied error whenever you try to save a file. 每当您尝试保存文件时,它都会抛出一个权限被拒绝的错误。 From what I've been able to find thus far it seems that UWP apps can't save in the install directory and that is likely what my app is trying to do. 从我迄今为止能够找到的内容看来,UWP应用程序似乎无法保存在安装目录中,这可能是我的应用程序尝试做的事情。

There are a number of code samples available online for taking a Win32 app written in C#, C, C++, etc. and having it use LocalAppData instead. 在线提供了许多代码示例,用于使用C#,C,C ++等编写的Win32应用程序,并使用LocalAppData代替。 Unfortunately, I'm not seeing anything that will help me with this application. 不幸的是,我没有看到任何可以帮助我应用此功能的内容。

Is there a way to make saving files work in this instance? 有没有办法让保存文件在这个实例中工作? I'm hoping that there is perhaps a way to say, "Hey, when I say save a file, I mean save it to the LocalAppData folder for this particular application." 我希望有一种方式可以说,“嘿,当我说保存文件时,我的意思是将它保存到这个特定应用程序的LocalAppData文件夹中。” This probably needs to be abstract, ideally a declarative part of the appx package that isn't in the QB64 code. 这可能需要是抽象的,理想情况下是appx包中不在QB64代码中的声明部分。 Any ideas? 有任何想法吗?

There are two options to fix it (and one way to hack it): 有两种方法可以解决它(以及一种破解它的方法):

  1. If the file saving is done from your code, change it to write to an accessible location instead, such as localappdata or temp. 如果文件保存是从您的代码完成的,请将其更改为写入可访问的位置,例如localappdata或temp。

  2. If the file saving is done in code you can't change, then you can use the new Package Support Framework to apply a fixup at runtime that redirects the file operations. 如果文件保存是在代码中完成的,则无法更改,则可以使用新的包支持框架在运行时应用重定向文件操作的修订。 This is a new framework coming as part of the 1809 update for Windows 10. At the time of this writing this may not be an option for you just yet. 这是一个新的框架,作为Windows 10的1809更新的一部分。在撰写本文时,这可能不适合您。 Here is the documentation: https://docs.microsoft.com/en-us/windows/uwp/porting/package-support-framework?context=/windows/msix/render 以下是文档: https//docs.microsoft.com/en-us/windows/uwp/porting/package-support-framework?context=/windows/msix/render

  3. A hacky way to solve it that you could try would be to add a launcher EXE to your package and make that the app's entrypoint. 你可以尝试解决它的一种hacky方法是在你的包中添加一个启动程序EXE并使其成为应用程序的入口点。 The launcher would then copy your actual EXE to a writeable location (localappdata, etc.) and then launch it from there. 然后启动器会将您的实际EXE复制到可写位置(localappdata等),然后从那里启动它。 All your file writes will then succeed. 然后,您的所有文件写入都将成功。

暂无
暂无

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

相关问题 如何从转换后的Win32应用程序调用UWP API。 (桌面应用程序转换器) - How to call UWP API from converted Win32 app. (Desktop App Converter) 如何在我的Win32应用程序中使用Desktop Bridge(百年纪念项目)转换为UWP的情况下测试商店许可证? - How to test store license in my Win32 app converted to UWP using Desktop Bridge (Project Centennial)? 如何从使用“Project Centennial converter”转换为UWP的Win32应用程序访问Windows.Services.Store命名空间以启用应用内购买? - How to access Windows.Services.Store namespace from a Win32 app converted to UWP with the “Project Centennial converter” to enable in-app purchases? 在 Win32 桌面应用程序上创建按钮时出错 - Error Creating a button on Win32 Desktop App 如何使用Win32 API在Windows的桌面窗口层次结构中的特定位置放置我的应用程序窗口? - How do I place my app window in a certain position in the desktop window hierarchy on Windows using win32 api? 如何从 UWP 应用程序中使用命令行 arguments 实现启动 win32 exe? - How do you implement Launching a win32 exe with command line arguments from an UWP app? 在 Win32 应用程序中,如何检索应用程序类别信息 - In a Win32 app, how to retrieve app category information Win32 GUI应用程序:如何将stderr消息放入消息框 - Win32 GUI app: how to get stderr messages into messagebox 如何检测非活动 Win32 应用程序中的最小化? - How do I detect minimization in an inactive Win32 app? 在vb.net应用Win32中使用Robocopy错误 - Using Robocopy in vb.net app Win32 error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM