Optimizing Applications for Windows 2000 Terminal Services and Windows nt server 0




Download 197.5 Kb.
bet49/49
Sana29.03.2021
Hajmi197.5 Kb.
#13691
1   ...   41   42   43   44   45   46   47   48   49

APPENDIX D



Displaying a Pop-up Message Box in a Remote Session from a Service
In the Windows 2000 operating system, the MessageBox* APIs check for the presence of an impersonation token when the MB_SERVICE_NOTIFICATION flag is specified. The impersonation token contains the session id of the client that is being impersonated and that is the session in which the pop-up message box is displayed. RPC based services can use this new MessageBox* feature in conjunction with client impersonation in order to make sure the message box is displayed in the client’s session. The following code demonstrates how an RPC service can take advantage of this feature. (Note, this works with any form of impersonation, not just with RPC services.)
RPC_STATUS RpcStatus;

int iResult;


//

// Impersonate the client. We do this before we call MessageBox*

// because the impersonation token contains the session id of

// our calling client.

//

RpcStatus = RpcImpersonateClient( NULL );



if( RpcStatus != RPC_S_OK ) {

return( STATUS_CANNOT_IMPERSONATE );

}
//

// Now that we’re impersonating, call the MessageBox* API with

// the MB_SERVICE_NOTIFICATION flag. This will redirect the popup

// to the client’s session.

//

iResult = MessageBox(



HWND,

TEXT(“Message to display to user in remote session”),

TEXT(“Caption of Message Box”),

MB_OK | MB_SERVICE_NOTIFICATION

);
//

// Stop Impersonating



//

RpcRevertToSelf();

Download 197.5 Kb.
1   ...   41   42   43   44   45   46   47   48   49




Download 197.5 Kb.

Bosh sahifa
Aloqalar

    Bosh sahifa



Optimizing Applications for Windows 2000 Terminal Services and Windows nt server 0

Download 197.5 Kb.