Definition for 16-bit programs:
USHORT EXPENTRY WinQueryExtIdFocus(PUSHORT pSessionId);
Definition for 32-bit programs:
USHORT APIENTRY16 WIN16QUERYEXTIDFOCUS(PUSHORT pSessionId); #define WinQueryExtIdFocus WIN16QUERYEXTIDFOCUS
Add to your *.def file, if linker complains about missing WIN16QUERYEXTIDFOCUS:
IMPORTS WIN16QUERYEXTIDFOCUS = PMSHAPI.86
When the Session Manager switches to another session (because of a DosSMSwitch() call), it internally calls if PM is present WinSetExtIdFocus() to notify it about the session switch.
This API can be used to query the last session told to PM.
Tests show that this API can be used to see if PM is the current foreground full-screen session. The DosQuerySysState() API with the parameter QSV_FOREGROUND_FS_SESSION should return the session ID of the current foreground session, which for PM is always 1. Unfortunately, it returns some other session ID, as it changes when the user changes the focus between windowed VIO applications.
The WinQueryExtIdFocus() returns the same session ID that is returned by DosQuerySysState() when the PM is in foreground, but returns a different one, if PM is in the background.