我使用GetWindowLong窗口api来获取c#中窗口的当前窗口状态. [DllImport("user32.dll")] static extern int GetWindowLong(IntPtr hWnd, int nIndex); Process[] processList = Process.GetProcesses(); foreach (Process theprocess in pro
[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上获得数字,但我得到的数字是-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);