cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
UserDave
Level 2

Wtsapi32.WTSQuerySessionInformationA to get WTSClientProtocolType

I've been trying with mixed luck to get the session type. Ironically I had this working at one point but it now fails to prove the correct answer.


#define WTS_CURRENT_SESSION -1
#define WTSClientProtocolType 16
#define WTS_CURRENT_SERVER_HANDLE 0

LONG nReturnBytes;
POINTER pointerToPointer;
SHORT nProtocol;
NUMBER nSuccess;
........
prototype stdcall Wtsapi32.WTSQuerySessionInformationA(NUMBER, NUMBER, NUMBER, POINTER, POINTER);
nSuccess = WTSQuerySessionInformationA(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSClientProtocolType, &pointerToPointer, &nReturnBytes);
nProtocol = *pointerToPointer;

The return value is always non-0 (aka success) but Unfortunately nProtocol is not 0,1, or 2.

What am I doing wrong?
Thank you,
Dave
Labels (1)
0 Kudos
(1) Reply
UserDave
Level 2

I've changed my code again and it works fine
prototype stdcall wtsapi32.WTSQuerySessionInformationA(NUMBER, NUMBER, NUMBER, BYREF POINTER, BYREF LONG);

LONG nReturnBytes;
POINTER pointerToPointer;

nSuccess = wtsapi32.WTSQuerySessionInformationA(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSClientProtocolType, pointerToPointer, nReturnBytes);

UNTIL the script calls
nResult = SdWelcome( szTitle, szMsg );
After which the values come back corrupted. Why would calls to this installshield function cause the DLL to go from working to failing?

Thanks.
0 Kudos