Solved

MessageBox from a Windows Service

Posted on 2004-09-13
2
7,677 Views
Last Modified: 2008-02-01
I need to show a dialog box when something occurs during the execution of a windows service, but it's impossible using MessageBox.Show(string). I need to use ServiceNotification or DefaultDesktopOnly but I don't know how to do it...

Any solution?

Thanks!

Enric.
0
Comment
Question by:EM77
2 Comments
 
LVL 14

Expert Comment

by:AvonWyss
ID: 12043375
Well, in the Windows Service management console, you can check a box saying that the service shall be allowed to interact with the desktop. This may be what you are looking for. But remember that services are not supposed to display things on the desktop to begin with (and that'y why the interact option is off by default)...
0
 
LVL 10

Accepted Solution

by:
123654789987 earned 50 total points
ID: 12051630
I found it!

I put the following code in the service OnStart event and I got a messageBox

System.Windows.Forms.MessageBox.Show("Service started on:","",System.Windows.Forms.MessageBoxButtons.YesNo,System.Windows.Forms.MessageBoxIcon.Question,System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.ServiceNotification);
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Login 17 50
C#.NET and microsoft certification. 3 40
Video Player 11 23
Disable Security Alert  popup in Winforms  embedded webbrowser. 1 30
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question