MessageBox in Out-of-Process COM Server
When you have a console b开发者_运维知识库ased client and a COM Server, can you call ::MessageBox(...) from the COM Server and expect it to work?
Yes, you can, but in some cases the box will be shown on another desktop and effectively block the calling thread, so you better not try this other than for debugging purposes.
You can use WTSSendMessage
function (see http://msdn.microsoft.com/en-us/library/aa383842.aspx and http://msdn.microsoft.com/en-us/library/ms683502.aspx) instead of MessageBox
.
To get the session id SessionId
you can use WTS_CURRENT_SESSION
or WTSEnumerateSessions
or WTSGetActiveConsoleSessionId
or GetTokenInformation
with TokenSessionId
and a clients token received during client impersonation. All depends on the scenarios which you have.
精彩评论