[UWP] UWP中的CreateFileMappingFromApp和OpenViewOfFileFromApp可用于与桌面/ WPF应用程序通信吗? [英] [UWP]Can CreateFileMappingFromApp and OpenViewOfFileFromApp in UWP be used to communicate with a desktop / WPF app?

查看:138
本文介绍了[UWP] UWP中的CreateFileMappingFromApp和OpenViewOfFileFromApp可用于与桌面/ WPF应用程序通信吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我担心这方面的文件不是很好。新方法被添加到文档中,但它们有很多指向旧CrateFileMapping ..例程的指针,我们知道这些例程在UWP下不起作用。


在我的测试中,我我无法发现这个例程的有用目的,虽然我知道我们经历了将它们添加到UWP的麻烦,但必须有一个。


内存映射似乎总是在SEssion \ AppContainerNameObjects ... ...中出现一个名字,它出现在沙盒中。要为每个应用程序提供唯一的ID,那么即使在一个UWP应用程序需要与另一个应用程序交谈的情况下,例程如何有用,
更不用说UWP可能通过共享与桌面应用程序通信的情况内存?


我的用例是一个旧桌面/ WPF程序,我需要与之共享内存。 我想编写一个UWP应用程序打开共享内存,该内存是使用CreateFileMapping和MapViewOfFile创建的,并由系统页面文件(不是文件,本身为
)支持。 同样,我希望我的UWP使用CreateFileMappingFromApp创建的任何共享内存对该桌面/ WPF应用程序可见。


如果这不是受支持的方案,请赐教至于在什么情况下可以使用--- fromApp例程,以及如何使用。 如果它是受支持的方案,请发送一段有效的代码片段,并允许以这种方式共享内存。


实验:

到目前为止,我已尝试使用无命名空间命名对象,"objectname",并且我尝试在"Global \"中命名对象。 space,"Global \objectname""

当我尝试"非命名空间对象时,该对象在AppContainer ...对象命名空间中的项目浏览器中显示,在这种情况下,它似乎没有其他过程可以达到它。


当我尝试"全局"时命名空间对象,对象"消失"来自进程资源管理器,即使创建和映射和视图似乎已成功。 无论是否在WinObj上显示,我都说不清楚,因为有
没有设施来搜索对象(快照!)。 但是,无论我在哪里手动搜索,我似乎都找不到我正在寻找的对象名称。 注意这用于在我使用"正常"时获得异常。 CreateFileMapping方法。


最后,当我尝试访问我试图放入"Global \"的对象时UWP应用程序中的命名空间,来自使用CreateFileMapping的WPF应用程序(注意:桌面版)WPF应用程序返回win32错误5 ERROR_ACCESS_DENIED。 我已经验证了
,因为该对象未在"Global \"下找到。并且没有额外的权限,WPF应用程序无法在"Global \"中创建。命名空间。


所以即使我"成功"了似乎在"Global \"中创建了对象来自UWP,我已经确认WPF无法看到它,它只是在"Global \"中创建另一个


我期待在这里获得一些见解。


-thanks

-e



< hr>

- 我 -

解决方案


我会请其他工程师看看这个。可能会有一些时间延迟。


感谢您的耐心等待。


祝您好运,


罗伊


I'm afraid that the documentation on this is just not very good. The new methods were added to the docs, but they have a lot of pointers to the old CrateFileMapping .. routines, which we know don't work under UWP.

In my tests, I was not able to uncover a useful purpose for this routines, although I know with the amount of trouble we went through to get them added to UWP, there must be one.

The memory mapping seems to always have a name inside the SEssion\AppContainerNameObjects...… sandbox which it appears  to have a unique ID for each app, so how would the routines be useful, even in the case of one UWP app needing to talk to another, let alone the case where UWP might talk to a desktop app through a shared memory?

My use case is an old desktop/WPF program that I need to share memory with.  I would like to write an UWP app that opens that shared memory, which was created with CreateFileMapping and MapViewOfFile, and backed by the system paging file (not a file, per se).  As well, I'd like any shared memory created by my UWP use of CreateFileMappingFromApp to be visible to that desktop/WPF app.

If this isn't a supported scenario, please enlighten me as to in what scenario the ---fromApp routines can be used, and how.  If it is a supported scenario, please send a snippet of code that works and will allow the sharing of memory in this way.

Experiments:
So far, I've tried naming objects using no namespace, "objectname", and I've tried naming objects in the "Global\" space, "Global\objectname"

when I try "non-namespace objects, the object is shown in project explorer in the AppContainer… object namespace, and in that case, it appears no other process can get to it.

when I tried "Global" namespace objects, the object "disappears" from process explorer, even though the creation and mapping and view seem to have succeeded.  Whether it is or isn't shown on WinObj, I cannot tell because there is no facility there to search for objects (snap!).  However, wherever I have searched manually, I don't seem to find the object name I'm seeking.  NOTE this used to get an exception when I used the "normal" CreateFileMapping method.

Finally, when I try to access that object that I tried to put in the "Global\" namespace in the UWP app, from the WPF app using CreateFileMapping (NOTE: desktop version) the WPF app returns win32 error 5 ERROR_ACCESS_DENIED.  This I've since verified is because the object was NOT found under "Global\" and that without additional privilege, the WPF app cannot create in the "Global\" namespace.

So even if I "successfully" seem to create the object in "Global\" from UWP, I've verified that WPF cannot see it, and it just creates one another one in "Global\"

I'm looking forward to some insights here.

-thanks
-e


-- me --

解决方案

Hi,

I will ask other engineers to take a look at this. There might be some time delay.

Thank you for your patience. 

Best regards,

Roy


这篇关于[UWP] UWP中的CreateFileMappingFromApp和OpenViewOfFileFromApp可用于与桌面/ WPF应用程序通信吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆