How can I use GetNextWindow() in C#?

前端 未结 2 1526
长发绾君心
长发绾君心 2021-01-02 15:26

The Microsoft WinAPI documentation appears to suggest that user32.dll contains a function called GetNextWindow() which supposedly allows one to enumerate open windows in the

相关标签:
2条回答
  • 2021-01-02 15:51

    GetNextWindow is a c++ macro that calls GetWindow, so you cannot call it from .NET. Call GetWindow instead.

    From MSDN:

    Using this function is the same as calling the GetWindow function with the GW_HWNDNEXT or GW_HWNDPREV flag set

    0 讨论(0)
  • 2021-01-02 16:07

    GetNextWindow() is actually a macro for GetWindow(), rather than an actual API method. It's for backward compatibility with the Win16 API.

    [DllImport("user32.dll", SetLastError = true)]
    static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd);
    
    enum GetWindow_Cmd : uint {
        GW_HWNDFIRST = 0,
        GW_HWNDLAST = 1,
        GW_HWNDNEXT = 2,
        GW_HWNDPREV = 3,
        GW_OWNER = 4,
        GW_CHILD = 5,
        GW_ENABLEDPOPUP = 6
    }
    

    (From Pinvoke.net)

    0 讨论(0)
提交回复
热议问题