我使用 GetWindowLong 窗口 api 来获取 C# 中窗口的当前窗口状态。
[DllImport("user32.dll")]
static extern int GetWindowLong(IntPtr hWnd, int nIndex);
Process[] processList = Process.GetProcesses();
foreach (Process theprocess in processList)
{
long windowState = GetWindowLong(theprocess.MainWindowHandle, GWL_STYLE);
MessageBox.Show(windowState.ToString());
}
我希望能得到数字http://www.autohotkey.com/docs/misc/Styles.htm http://www.autohotkey.com/docs/misc/Styles.htm,但我得到的数字如 -482344960、-1803550644 和 382554704。
我需要转换 windowState 变量吗?如果是的话,做什么?
这些值有什么奇怪的?例如,482344960
相当于0x1CC00000
它看起来像您可能期望看到的窗口样式。查看您链接到的样式参考,即WS_VISIBLE | WS_CAPTION | 0xC000000
.
如果您想测试WS_VISIBLE
,例如,您会执行以下操作:
int result = GetWindowLong(theprocess.MainWindowHandle, GWL_STYLE);
bool isVisible = ((result & WS_VISIBLE) != 0);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)