I am writing a console application that will be launched from services in hidden mode. Sometimes I want to make a pop-up window with information about the error for some errors. Is it possible and, if possible, how to implement?

PS The application should not freeze because of the window.
PPS The window is normal with the "OK" button and you can also give an example with notification in the tray.

  • Which window? Normal dialogue or tray notification? - Vladimir Martyanov
  • @ Vladimir Martian ordinary. But in the tray, too, will need. - Dmitry
  • The service window is a very bad decision. Like notification to tray. After all, services can work on a server where no one is logged in, or vice versa several users are logged in A good solution is to write in events. + You can make a normal user application, which will sit in the tower, interrogate the service and show the user everything you need. - tonal

2 answers 2

Normal window - MessageBox in a separate thread. Notification in the tray - Shell_NotifyIcon and others like it. But I'm not sure that the console application of tray will work correctly, I have not tried it.

  • s_str to help. WinAPI is a user interface and knows nothing about std :: string. - Vladimir Martyanov
  • one
    LPCWSTR - unicode string, if you want to use ASCII change Unicode support in project settings or try to explicitly specify the type of function: MessageBoxA - Vladimir Martyanov
  • Well here it is necessary to look how often you should obviously prescribe type of function. I change the settings in projects in 99% of cases. - Vladimir Martyanov

I think MessageBox is exactly what you need. Set the first parameter of the function to NULL .

It is somewhat more difficult to work through the tray; there is more than one function there, but it is also quite accessible from such an “console without console” application. I, at least, works.