1

I'm trying to find out if a window belongs to the current virtual desktop.

I found the VirtualDesktopManager class form the winapi, but even though it is supposed to be in the "shobjidl.h" header according to here, when I compile the code it throws this error:

85:5: error: 'VirtualDesktopManager' was not declared in this scope

important piece of my code:


    #include <shobjidl.h>

    ...

    BOOL is_on_current_desktop = FALSE;
    VirtualDesktopManager g_pvdm;
    g_pvdm.IsWindowOnCurrentVirtualDesktop(hwnd, &is_on_current_desktop);  // hwnd is a window handle acquired previously
    g_pvdm.Release();

How could I make this work?

  • You need `NTDDI_VERSION` to be set to `NTDDI_WIN10` or greater. https://docs.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers – Jonathan Potter Jun 05 '20 at 21:10

1 Answers1

0

Apparently this interface was not included in the "shobjidl.h" header in mingw64 which I was using, running it in Visual Studio it finds it. So the issue was in the header.

  • Hi makes-sense, feel free to [accept your own answer](https://stackoverflow.blog/2009/01/06/accept-your-own-answers/). – Rita Han Jun 16 '20 at 06:24