获取当前进程的HWND [英] Getting HWND of current Process

查看:1065
本文介绍了获取当前进程的HWND的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在c ++的进程,其中我使用窗口API。我想得到自己进程的HWND。

I have a process in c++ in which I am using window API. I want to get the HWND of own process. Kindly guide me how can I make it possible.

推荐答案

假设一个进程只有一个HWND。这通常不是真的,因此Windows不能提供API来获取它。程序可以创建两个窗口,并且有两个HWND作为结果。 OTOH,如果你的程序只创建一个窗口,它可以将该HWND存储在一个全局变量中。

You are (incorrectly) assuming that a process has only a single HWND. This is not generally true, and therefore Windows can't offer an API to get it. A program could create two windows, and have two HWNDs as a result. OTOH, if your program creates only a single window, it can store that HWND in a global variable.

这篇关于获取当前进程的HWND的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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