C# 十六进制值到 IntPtr
我有一个使用 Spy++ 找到的窗口的十六进制值。
该值是: 00010010
感谢我之前提出的问题的答案,我有这样的代码:
IntPtr hwndf = this.Handle;
IntPtr hwndParent = FindWindow("WINDOW HERE", null); ;
SetParent(hwndf, hwndParent);
this.TopMost = false;
现在,据我了解, IntPtr hwndParent 将包含窗口 WINDOW HERE 的句柄。我如何重写该行以使用我的十六进制句柄?我尝试过:
IntPtr hwndParent = (IntPtr) 0x00010010
但没有成功。有什么想法吗?
I have a hex value to a window i found using Spy++.
the value is: 00010010
Thanks to an answer to a question i asked earlier, i have this code:
IntPtr hwndf = this.Handle;
IntPtr hwndParent = FindWindow("WINDOW HERE", null); ;
SetParent(hwndf, hwndParent);
this.TopMost = false;
Now, as far as i understand it, IntPtr hwndParent will contain the handle to the window WINDOW HERE. How can i rewrite that line to use my hex handle? I tried:
IntPtr hwndParent = (IntPtr) 0x00010010
But it didnt work. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
那么,00010010 的十六进制等效值是 0x12。所以理论上你可以使用
Windows 计算器来完成这种转换。不过,这个值听起来并不正确。您能更详细地解释一下您是如何获得该值的吗?
编辑:您的评论提到您正在尝试获取桌面窗口的句柄。有一个函数:GetDesktopWindow,它返回一个 IntPtr。如果您只对桌面窗口感兴趣,请使用它。
这是该函数的 P/Invoke:
Well, the hex equivalent of 00010010 is 0x12. So you could theoretically use
The Windows calculator can do that conversion. That value doesn't sound correct, though. Can you explain in more detail how you got that value?
EDIT: Your comment mentions that you're trying to get a handle to the desktop window. There's a function for that: GetDesktopWindow, which returns an IntPtr. If all you're ever interested in is the desktop window, use that.
Here's the P/Invoke for that function:
IntPtr 的构造函数接受一个初始化参数:
The constructor of IntPtr accepts an initialization parameter:
尝试:
Try:
这应该有效
This should work
既然您正在谈论这个问题:您似乎不想创建一个小部件/窗口位于桌面顶部但位于另一个窗口顶部?
如果是这样,为什么不使用 FindWindow() 来查找该窗口呢?
为什么是常数值?
Since you're talking about this question: It seems you don't want to create a widget/window on top of the desktop but on top of another window instead?
If that's the case, why don't you use FindWindow() to - find that window?
Why a constant value?