Sends a message to the windowstation & active desktop for the specified session.
wtsSendMessage(server,session,title,message,style,timeout,wait-flag)
(s) server: This is the name of the terminal server system to which the message will be sent. 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) session: This is a session id number that identifies the session to which the message will be sent.
(s) title: This is the title text for the message box.
(s) message: This is the message text for the message box.
(i) style: This is an integer that defines how the message box will appear. Refer to the "Notes:" section for more information about the values that are defined for this parameter.
(i) timeout: This is an integer that indicates how many seconds this function should wait for a user to acknowledge the message box [e.g. click a button on it] before returning a value that indicates that the message box timed out w/o being acknowledged.
If the wait-flag parameter is @FALSE, then the timeout parameter value is ignored and this function will immediate return with a result value that indicates that it has completed asynchronously.
If the wait-flag parameter is @TRUE and the timeout parameter value is zero, then this function will wait indefinitely for a user to acknowledge the message box.
(i) wait-flag:This is flag value that can be either @TRUE or @FALSE, and it controls whether or not this function waits for a user to acknowledge the message box before returning control to the script that called this function.
Returns:(i) Returns an integer indicating one of the following: A button was clicked to acknowledge the message box,The message box timed out w/o being acknowledged, The function completed asynchronously and did not wait for the messsage box to be acknowledged. Refer to the "Notes:" section for more information regarding the actual return values that are defined for this function.
Notes:
This function can display a message box in any terminal services session. This function can also wait for a user to acknowledge the message box and can then determine whichbutton was clicked.
The following return values are defined:
Value |
Meaning |
1 |
The "OK" button was clicked. |
2 |
The "Cancel" button was clicked. |
3 |
The "Abort" button was clicked. |
4 |
The "Retry" button was clicked. |
5 |
The "Ignore" button was clicked. |
6 |
The "Yes: button was clicked. |
7 |
The "No" button was clicked. |
32000 |
The message box timed out w/o being acknowledged. |
32001 |
This function was called with a value of @FALSE for the wait-flag parameter. |
The message box "style" parameter is actually a bit-mask value consisting of different components that determine what buttons are present, what icons are present and how the message box itself actually gets presented in the specified session on the specified terminal server. A single value from each of the following categories must be combined with a bit-wise OR operation to come up with a single numeric value that represents the style parameter.
Button Category:
Value |
Meaning |
0 |
The message box will have an "OK" button. |
1 |
The message box will have an "OK" and "Cancel" buttons. |
2 |
The message box will have "Abort", "Retry" and "Ignore" buttons. |
3 |
The message box will have "Yes", "No" and "Cancel" buttons. |
4 |
The message box will have "Yes" and "No" buttons. |
5 |
The message box will have "Retry" and "Cancel" buttons. |
Icon Category:
Value |
Meaning |
16 |
The message box will have a hand icon. |
32 |
The message box will have a question mark icon. |
48 |
The message box will have an exclamation mark icon. |
64 |
The message box will have an asterisk icon. |
Default Button Category:
Value |
Meaning |
0 |
The first button in the message box is the default button. |
256 |
The second button in the message box is the default button. |
512 |
The third button in the message box is the default button. |
For example, if I want a message box that has Abort/Retry/Ignore buttons, a question mark icon and I want the "Ignore" button to be the default button, then following expression would be used to combine these style flag bits into a single bit-mask value:
Style = 2 | 32 | 512
;Load 32-bit or 64-bit extender AddExtender( "WWWTS44I.DLL" , 0, "WWWTS64I.DLL" )
Title01 = 'Test wtsSendMessage()' ServerSpec = AskLine('Send a message','Server','') SessId = AskLine('Send a message','Session Id #','') TitleText = AskLine('Send a message','Title text','') MsgText = AskLine('Send a message','Message text','') MsgStyle = AskLine('Send a message','Message Style','0') MsgTimeout = AskLine('Send a message','Timeout','0') MsgWait = AskLine('Send a message','Wait flag','1') ErrorMode(@OFF) Result = wtsSendMessage(ServerSpec,SessId,TitleText,MsgText,MsgStyle,MsgTimeout,MsgWait) RC = LastError() ErrorMode(@CANCEL) TempMsg = StrCat('wtsSendMessage("',ServerSpec,'",',SessId,',"',TitleText,'","',MsgText,'",',MsgStyle,',',MsgTimeout,',',MsgWait,') RC = ',RC) TempMsg = StrCat(TempMsg,@CRLF,@CRLF,'Result = ',Result) Message(Title01,TempMsg) Exit