Tuesday, September 30, 2014

Display Message From Service/Session 0

The conventional methods to show message box are MessageBox()/AfxMessageBox(). But is it useful if we want to display messages from a service/an application running in session 0?  Yes you can but it is not  convenient. The developer has to enable interactive services
There is an alternative method which uses WTSSendMessage() .

DWORD dwSession = WTSGetActiveConsoleSessionId();
DWORD dwResponse = 0;
LPWSTR lpwszMessage = L"Hellow VC++ From Session 0";
WTSSendMessage(WTS_CURRENT_SERVER_HANDLE, dwSession,L"",0, lpwszMessage, wcslen(lpwszMessage)* sizeof(wchar_t), 0, 0, &dwResponse, FALSE);

No comments:

Post a Comment

Keep an eye on your Native API prototype for interop calls

Few weeks back, we have observed "an unexpected process termination" crash in a WPF app. From the crash dump, provides below calls...