Wiki Home

Terminal Services


Namespace: WIN_COM_API
Every Win 2 K server comes with 2 remote administration licenses out of the box.

While It seems to be much quicker than Vn C. It doesn't allow you to control the current desktop (it provides each session with a desktop of its own) and you need to log on as a user with administrative privileges. (Note that you can configure Vn C to support localhost 'loopback' connections, so you could Terminal - Service into a box and then use a Vn C viewer to access the Vn C server on the same box to access the desktop. Gives you the security (?) of Terminal Services with desktop access. -- Ted Roche) - see 'console session' below - Nigel

Note that running in Remote Administration mode doesn't seem to degrade application performance in the same way that running in standard mode does. In other words, the server is actually useful for something other than serving TS sessions.

To connect to a Windows 2003 server as the 'console' session : C:\Windows\System32\mstsc.exe /console /v:servername
Note: Vista SP1 changes /console to /admin.
this code will ensure a VFP App in a TS session shuts down if the session is logged out or disconnected.


** WTSRegisterSessionNotifiction flags
#DEFINE NOTIFY_FOR_THIS_SESSION		0

#DEFINE WM_WTSSESSION_CHANGE		0x02B1

** session notification message flags
#DEFINE WTS_CONSOLE_CONNECT		0x1
#DEFINE WTS_CONSOLE_DISCONNECT		0x2
#DEFINE WTS_REMOTE_CONNECT		0x3
#DEFINE WTS_REMOTE_DISCONNECT		0x4
#DEFINE WTS_SESSION_LOGON		0x5
#DEFINE WTS_SESSION_LOGOFF		0x6
#DEFINE WTS_SESSION_LOCK		0x7
#DEFINE WTS_SESSION_UNLOCK		0x8
#DEFINE WTS_SESSION_REMOTE_CONTROL	0x9


PUBLIC goTSNotify
goTSNotify = CREATEOBJECT("tsNotify")
IF goTSNotify.sessionid > 0
	DECLARE INTEGER WTSRegisterSessionNotification IN Wtsapi32;
		INTEGER hWindow,;
		LONG dwFlags
	=WTSRegisterSessionNotification(_VFP.HWND,NOTIFY_FOR_THIS_SESSION)
	=BINDEVENT(_VFP.HWND,WM_WTSSESSION_CHANGE,goTSNotify,"onsessionchange")
ENDIF

DEFINE CLASS tsNotify AS CUSTOM
	sessionid = 0
	PROCEDURE INIT
		#DEFINE SM_REMOTESESSION 0x1000
		IF VAL(OS(3)) => 5
			DECLARE INTEGER GetSystemMetrics IN WIN32API INTEGER
			THIS.sessionid= GetSystemMetrics(SM_REMOTESESSION)
		ENDIF
	ENDPROC
	PROCEDURE onsessionchange
		LPARAMETERS HWND,uint,wparam,LPARAM
		IF wparam = WTS_SESSION_LOGOFF OR wparam = WTS_REMOTE_DISCONNECT
			QUIT
		ENDIF
	ENDPROC
ENDDEFINE


(Nigel Gomm)


Also See: Terminal Services Advanced Client
Contributors Andrew Coates Ted Roche
Category Thin Client
( Topic last updated: 2008.02.15 09:44:35 AM )