开发者

MessageBox in Out-of-Process COM Server

开发者 https://www.devze.com 2023-01-04 18:44 出处:网络
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 insome cases the box will be shown on

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

精彩评论

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