Waits for one or more terminal services related events to occur.
wtsWaitSystemEvent(server,event-mask)
(s) server: This is the name of the terminal server system which will be monitored for terminal services related events. The server name should have the leading "\\" characters on it. Passing in an empty string for this parameter will cause the local terminal server system to be used.
(i) event-mask: This is number that represents a bit-mask value containing bits that correspond to various terminal services events that can occur. Refer to the "Notes:" section for more information regarding what bit values are defined.
(i) Returns an integer that contains a bit-value indicating what event occurred. Refer to the "Notes:" section for more information regarding the return values.
This function waits for a terminal services related system event to occur, at which time it returns a bit-mask value indicating which particular event happened.
The following bits values are defined for the event-mask parameter:
Value |
Meaning |
1 |
"Create" - A windowstation was created. |
1 |
"Delete" - A windowstation was deleted. |
4 |
"Rename" - A windowstation was renamed. |
8 |
"Connect" - A connection was made to an existing windowstation. |
16 |
"Disconnect" - A an existing connection to a windowstation was broken. The windowstation is now in the "DISCONNECTED" connection state. |
32 |
"Logon" - A user logged on to a windowstation. |
64 |
"Logoff" - A user logged off from a windowstation. |
128 |
"State Change" - A windowstation has changed its connection state. |
256 |
"License" - The terminal server's licensing has changed due to a license being added or removed using the license manager. |
Any of the bits that have non-zero values may be combined into a single bit-mask value using the bit-wise OR operator. For example, to get a bit-mask value that will cause wtsWaitSystemEvent() to wait for both logon and logoff events, do the following:
EventMask = 32 | 64
If you want to wait for all events, use the value 2147483647 [with commas to make it more readable, thats 2,147,483,647].
If you are examining the return value of this function, then to test for any particular bit being set in the bit-mask value, you need to use the bit-wise AND operator as follows:
Result = wtsWaitSystemEvent('',2147483647)
if ((Result & 32) != 0)
; We had a logon event
endif
if ((Result & 64)
; We had a logoff event
endif
;Load 32-bit or 64-bit extender AddExtender( "WWWTS44I.DLL" , 0, "WWWTS64I.DLL" )
Title01 = 'Test wtsWaitSystemEvent()' ServerSpec = AskLine('Terminate a process','Server','') EventMask = AskLine('Terminate a process','Event mask #','') ErrorMode(@OFF)Result = wtsWaitSystemEvent(ServerSpec,EventMask) RC = LastError() ErrorMode(@CANCEL) TempMsg = StrCat('wtsWaitSystemEvent("',ServerSpec,'",',EventMask,') RC = ',RC,@CRLF) TempMsg = StrCat(TempMsg,@CRLF,@CRLF,'Result = ',Result) Message(Title01,TempMsg) Exit