简体   繁体   English

在Windows CE 6.0中的进程之间共享GDI句柄

[英]Sharing GDI handles between processes in Windows CE 6.0

I know that GDI handles are unique and process specific in 'Big Windows' but do they work the same way in Windows CE 6.0? 我知道GDI句柄在“ Big Windows”中是唯一的并且特定于进程,但是在Windows CE 6.0中它们是否以相同的方式工作?

For example: I've got a font management service that several other services and applications will be using. 例如:我有一个字体管理服务,其他一些服务和应用程序将使用它。 This service has a list of valid fonts and configurations for printing and displaying; 该服务具有用于打印和显示的有效字体和配置的列表; CreateFontIndirect() has been called on each of them. 在每个函数上都调用了CreateFontIndirect()。 When one of these client applications requests a particular font (and configuration), can I return it the appropriate HFONT? 当这些客户端应用程序之一请求特定的字体(和配置)时,我可以将其返回适当的HFONT吗? If not, is there a safe/valid way to duplicate the handle, ala DuplicateHandle for Kernel handles. 如果不是,是否存在一种安全/有效的方法来复制该句柄,所以对于内核句柄来说,它就是DuplicateHandle。

The reason I ask, is that I've seen HFONTs passed to another application through PostMessage work correctly, but I didn't think they were 'supposed' to. 我问的原因是,我已经看到通过PostMessage传递给另一个应用程序的HFONT可以正常工作,但是我不认为它们是“应有的”。

I believe you are correct, you cannot rely on HFONTs being safe to pass across processes. 我相信您是正确的,您不能依靠HFONT安全地跨流程传递。

'The reason I ask, is that I've seen HFONTs passed to another application through PostMessage work correctly, but I didn't think they were 'supposed' to.' “我问的原因是,我已经看到通过PostMessage传递给另一个应用程序的HFONT可以正常工作,但是我不认为它们是“应有的”。

They were not passed correctly, so there is no 'supposed to'. 它们没有正确通过,因此没有“本应”。 While HFONTs are not guaranteed to work across processes, they're also not guaranteed to be unique across processes. 虽然不能保证HFONT在整个流程中都可以工作,但也不保证在整个流程中它们都是唯一的 'Arial' may have the same HFONT value in two difference processes at a point in time with a particular version of each application, and could change at any moment (including half-way through using it!) “ Arial”在每个应用程序的特定版本的某个时间点的两个不同过程中可能具有相同的HFONT值,并且可能随时更改(包括使用过程中途!)。

It's like if I'm painting, and run out of orange paint, which i keep as the 3rd tube on my easle. 就像我正在绘画,并且用完橙色颜料一样,我将其保留为我的第三根管。 I could reach for your easle and grab the 3rd tupe... but i have no guarantee that it's orange... i have no guarantee that it even contains paint! 我可以伸手去拿第三根铅笔...但是我不能保证它是橙色的...我不能保证它甚至包含油漆! Perhaps you were brushing your teeth at the easle today.. oops! 也许您今天在刷牙在刷牙..哎呀!

GDI handles are like the number '3' in that example. GDI句柄在该示例中类似于数字“ 3”。 Today, GDI might keep the tubed in the same order on all easles. 如今,GDI可能会将所有导管上的导管保持相同的顺序。 It might keep some of them in order, some not (ie, orange 'sorta works', but 'seafoam green' is busted). 它可能会使其中一些保持秩序,而有些则无法保持秩序(即橙色的“ sorta作品”,但是“ seafoam green”被破坏)。 They could be in order on one CE device, but not on another. 它们可能在一个CE设备上是按顺序排列的,但在另一个CE设备上不是。

As always, YMMV. 与往常一样,YMMV。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM