This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

w32api 3.13-1 Incorrect #define of WTS_CURRENT_SESSION in wtsapi32.h

In w32api, the definition of WTS_CURRENT_SESSION in wtsapi32.h is

#define WTS_CURRENT_SESSION       0

However, from the Microsoft Windows SDK for Windows Server 2008 and .NET
Framework 3.5
4207-8586-711EBE331CDC&displaylang=en), the definition is 

 *  Specifies the current session (SessionId)

This results in the wrong session being referenced when used in WTS API
calls such as WTSQuerySessionInformation. The following small example
demonstrates the problem: when I run this over an RDP connection to my
Windows box (logged in as an admin user), it prints
  Is a remote connection: 0
which is obviously incorrect. If the "WTS_CURRENT_SESSION" is changed to
"-1", then the expected result
  Is a remote connection: 1
is returned.

/* Compile with gcc -Wall -DWINVER=0x0501 -o test-wts test-wts.c
-lwtsapi32 */

#include <windows.h>
#include <wtsapi32.h>
#include <stdio.h>

int main(void) {
  USHORT *clnProto;
  DWORD size;

  if (WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE,
WTS_CURRENT_SESSION, WTSClientProtocolType, (LPTSTR *)&clnProto, &size))
    printf("Is a remote connection: %d\n", (*clnProto != 0));
  return 0;


Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]