简体   繁体   English

内存映射文件是否作为 uwp 应用程序和 win32 进程之间的 ipc 支持

[英]Is Memory-mapped-files as ipc between uwp app and win32 process supported

The official docs doesn't properly state if ipc via memory-mapped-files is supported in uwp. I was working on a scenario for ipc between an uwp app and its desktop extension.如果 uwp 支持通过内存映射文件的 ipc,官方文档不正确 state。我正在研究 uwp 应用程序及其桌面扩展之间的 ipc 场景。 While I can create memory-mapped-files using System.IO.MemoryMappedFiles from uwp app with codeGeneration capability but opening from win32 process fails with message Unable to find the specified file.虽然我可以使用具有codeGeneration System.IO.MemoryMappedFiles内存映射文件,但从 win32 进程打开失败并显示消息Unable to find the specified file. . . Is ipc via memory-mapped-files supported in uwp, if yes, what is the proper way to do it?? uwp 是否支持通过内存映射文件的 ipc,如果是,正确的方法是什么?

Minimal reproduceable sample. 最小可重现样本。

Update 1更新 1

Updated sample implementing answer from @Peter Torr - MSFT. 更新了来自@Peter Torr - MSFT 的示例实现答案。

Update 2更新 2

Working sample in which memory-mapped-file created from uwp app can be read by win32 process. 工作示例,其中从 uwp 应用程序创建的内存映射文件可以被 win32 进程读取。 Reading memory-mapped-file in uwp app created by win32 process still isn't working.读取由 win32 进程创建的 uwp 应用程序中的内存映射文件仍然无法正常工作。

Yes it is supported, but if you're creating the object in a UWP context and opening it from a Desktop context then the Desktop process needs to explicitly use the namespace of the named object.是的,它受支持,但如果您在 UWP 上下文中创建 object 并从桌面上下文打开它,则桌面进程需要显式使用命名空间 object。

From within your UWP process, call GetAppContainerNamedObjectPath(nullptr, nullptr, ...) to determine what that namespace is, and then add a backslash and your mapped file name to the end.在您的 UWP 进程中,调用GetAppContainerNamedObjectPath(nullptr, nullptr, ...)以确定该名称空间是什么,然后在末尾添加反斜杠和您的映射文件名。 It will be something like AppContainerNamedObjects\S-1-15-2-xxxxxxx\YourMappedName它将类似于AppContainerNamedObjects\S-1-15-2-xxxxxxx\YourMappedName

You should only need to do this once, unless you change your package name (including the publisher hash).您应该只需要执行一次,除非您更改您的 package 名称(包括发布者哈希)。 So once you have generated it, you can hard-code the value into your desktop app and forget about it.因此,一旦您生成了它,您就可以将该值硬编码到您的桌面应用程序中,然后将其抛在脑后。

Note that if you do it the other way around - Desktop creates the object, and UWP opens it - then you don't need to worry about the namespace, but you have to modify the access control instead, which is trickier.请注意,如果您以相反的方式进行 - Desktop 创建 object,然后 UWP 打开它 - 那么您无需担心命名空间,但您必须改为修改访问控制,这比较棘手。

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

相关问题 从主UWP进程终止UWP应用的Win32进程,或向其发送消息 - Terminate the win32 process of UWP app from main UWP process, or send message to it 如何通过后台 Win32 进程使用全局快捷方式启动 UWP 应用程序? - How to start a UWP app with a global shortcut through a background Win32 process? 我无法在 UWP 应用程序和 Win32 应用程序之间通信 - I can't communicate between UWP app and Win32 app 我可以从 UWP 应用程序的进程外后台任务中启动 FullTrust Win32 应用程序吗? - Can I launch a FullTrust Win32 app from within a UWP app's out-of-process background task? WinUI(Win32 和 UWP)在调整大小方面滞后 - WinUI (Win32 and UWP) lags in resizing UWP 启动 Win32 控制台应用程序与 Process.Start 一起工作 - UWP Starting Win32 Console Application works with Process.Start works Win32和UWP之间进行通信时,SendMessageAsync随机引发异常 - SendMessageAsync throws exception randomly when communicating between Win32 and UWP 我的Win32 App如何从UWP App窃取焦点? - How Can My Win32 App Steal Focus From My UWP App? 如何从 UWP 应用程序中使用命令行 arguments 实现启动 win32 exe? - How do you implement Launching a win32 exe with command line arguments from an UWP app? Win32强制窗口模式在进程中 - Win32 force windowed mode on process
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM