im programing for a windows service.

if i get an error in d program, how do i display it.

that is while running the service, if i get an error, how do i display it

Re: Visual C++ General windows service


A couple of options follows. Combine as you will.

  1. Write the error message to event log.
  2. Attach the service to a desktop (it's not connected to one by default), using SetProcessWindowStation / SetThreadDesktop.
  3. Write a frontend application which connects to the service to receive status information, such as a notification area icon which shows a popup.

Re: Visual C++ General windows service

Bruno van Dooren

You don't.

There is a flag in the service properties tab called 'allow service to interact with the desktop' but you should not do that because

a) that's a serious security risk

b) you don't know who is logged on so the user might not be able to understand what is happening

c) you cannot use simple dialog boxes anyway because they could block the service.

What you do is you log the error in the windows event log or in a dedicated log file (basic solution).

Or you have an application icon in the system tray that will display the status of your service (more elegant solution).

There are other things you can think of (like a status app that communicates with the service) but the important part is that your service should never interact directly with the desktop.