Show messages in console from windows service

2019-09-07 20:08发布

When i double click on my server exe it runs as a console application and i can see the logs in console. I have made a windows service using the code given at http://code.msdn.microsoft.com/windowsdesktop/CppWindowsService-cacf4948 Using this the server runs in background but i cant see the console. Can anyone tell me how can i send messages to the console from a service??

Thanks!

2条回答
We Are One
2楼-- · 2019-09-07 20:25

Starting from Windows Vista the services are executed in a different session so most communications will not work.

http://msdn.microsoft.com/en-us/library/windows/hardware/gg463353.aspx

Microsoft have some ways to communicate with services as described here (only first paragraph).

http://msdn.microsoft.com/en-us/library/windows/desktop/ms683502%28v=vs.85%29.aspx

查看更多
疯言疯语
3楼-- · 2019-09-07 20:44

Got it! I print my logs from my service to a pipe handle and i just wrote a simple pipe client which reads the file and displays it in the console. If anyone needs the code then ill post it here

Thanks!

查看更多
登录 后发表回答