开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜