Windows Services Popup MessageBox dialog box

Source: Internet
Author: User

Windows Services Popup MessageBox dialog box

Since Windows upgraded to Vista version, the system service is not allowed to pop up those extremely brutal messagebox (as for why not to let pop-up, the principle is a little complicated, I am not very clear, just a little bit, here is not embarrassing, self-Google bar), However, no matter how wonderful, there is always the need to eject the MessageBox from the service, so see the relevant cheats at home and abroad, there is a way to help us pop up this dialogue, the following is the implementation of the code (the specific meaning of internal functions MSDN detailed understanding).

#include <windows.h>
#include <WtsApi32.h>
#pragma comment (lib, "WtsApi32.lib")
BOOL Svcmessagebox (LPSTR lpcap, LPSTR lpmsg, DWORD style, DWORD &result)

if (NULL = = Lpmsg | | NULL = = Lpcap)
return FALSE;
result = 0;
DWORD Sessionxid = Wtsgetactiveconsolesessionid ();
Return Wtssendmessage (Wts_current_server_handle, Sessionxid,
Lpcap, strlen (Lpcap),
Lpmsg, strlen (lpmsg),
Style, 0, &result, FALSE);


When compiling the code, maybe vs will prompt you not to find the Wtsgetactiveconsolesessionid () function, because the function is supported from the version of Windows XP, so there is no such function on the old version system. And your project is to upgrade from the old code, such as the definition of _win32_winnt as 0x0500, the solution is as follows:
#define _WIN32_WINNT 0x0501
About these hexadecimal represents the specific meaning of your own MSDN bar.

Pop-up dialog is the user's current process, so pop-up dialog box does not block the service process, the server can not judge the function's return value to make a decision, this is very awkward, there is no Daniel encountered the problem, please point twos.
At the same time in Windows also saw other services, pop up as shown in the dialog box, feel very cool, than the MessageBox user experience is much better, but do not know how to achieve, kneeling to achieve the method ah.

How can this be achieved?

Windows Services Popup MessageBox dialog box

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.