如何与另一个应用程序共享HGLOBAL? [英] How to share HGLOBAL with another application?

查看:205
本文介绍了如何与另一个应用程序共享HGLOBAL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解 HGLOBAL 的一些东西,因为我刚刚发现我的想法是错误的。



在应用程序AI GlobalAlloc()数据( GMEM_SHARE | GMEM_MOVABLE )中, c $ c>Test。现在,我可以给另一个应用程序来获取这些数据?



我虽然(错误!) HGLOBAL HGLOBAL 是一个 HANDLE 到全局数据,所有的进程都是有效的,而不是指向全局数据的指针(这就是我说的OHHHH!)。



那么如何传递 HGLOBAL 到另一个应用程序?



注意:我想传递一个指针到数据,而不是数据本身, p>

非常感谢! : - )

解决方案

阅读文档。随着32位处理的引入, GlobalAlloc()实际上不再分配全局内存。



要共享一个内存块与另一个进程,您可以分配与 GlobalAlloc()块,并把它放在剪贴板,然后让其他进程检索它。或者你可以使用 CreateFileMapping() MapViewOfFile()分配一块共享内存。


I'm trying to understand something about HGLOBALs, because I just found out that what I thought is simply wrong.

In app A I GlobalAlloc() data (with GMEM_SHARE|GMEM_MOVABLE) and place the string "Test" in it. Now, what can I give to another application to get to that data?

I though (wrongfully!) that HGLOBALs are valid in all the processes, which is obviously wrong, because HGLOBAL is a HANDLE to the global data, and not a pointer to the global data (that's where I said "OHHHH!").

So how can I pass the HGLOBAL to another application?

Notice: I want to pass just a "pointer" to the data, not the data itself, like in the clipboard.

Thanks a lot! :-)

解决方案

Read the documentation. With the introduction of 32-bit processing, GlobalAlloc() does not actually allocate global memory anymore.

To share a memory block with another process, you could allocate the block with GlobalAlloc() and put it on the clipboard, then have the other process retreive it. Or you can allocate a block of shared memory using CreateFileMapping() and MapViewOfFile() instead.

这篇关于如何与另一个应用程序共享HGLOBAL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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