加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

GetWindowLong(int hWnd,GWL_STYLE)在c#中返回奇怪的数字

发布时间:2020-12-16 01:31:45 所属栏目:百科 来源:网络整理
导读:我使用GetWindowLong窗口api来获取c#中窗口的当前窗口状态. [DllImport("user32.dll")] static extern int GetWindowLong(IntPtr hWnd,int nIndex); Process[] processList = Process.GetProcesses(); foreach (Process theprocess in processList) { long w
我使用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上获得数字,但我得到的数字是-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);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读