Determine if a VM is running full screen from a process running on the VM

David Downing 701 Reputation points
2021-04-14T20:12:44.563+00:00

I have a service that is running on a VM running Windows and I need to determine if the VM window is running full screen. Is this possible?

I have already tried investigating the following without success:

    [DllImport("user32.dll")]
    static extern IntPtr GetDesktopWindow();

    [DllImport("user32.dll", SetLastError = true)]
    static extern int GetWindowLong(IntPtr hWnd, int nIndex);

    [DllImport("user32.dll")]
    [return: MarshalAs(UnmanagedType.Bool)]
    static extern bool GetWindowRect(HandleRef hWnd, out RECT lpRect);

    var expStyle = GetWindowLong((IntPtr)5160, (int)GWL.GWL_STYLE);
    var result = GetWindowRect(new HandleRef(GetConsoleWindow(), GetDesktopWindow()), out rect);
Remote Desktop
Remote Desktop
A Microsoft app that connects remotely to computers and to virtual apps and desktops.
4,254 questions
{count} votes

Accepted answer
  1. Karlie Weng 14,411 Reputation points Microsoft Vendor
    2021-04-23T02:44:52.92+00:00

    Hello David,

    I guess modify rdp file cannot realize this feature. This may still need the help with some code.

    You could try post this in Stack Overflow which is an open community for anyone with codes.

    Best regards
    Karlie

    ----Please "Accept as answer" if the reply is helpful-----

    0 comments No comments

0 additional answers

Sort by: Most helpful