0

as a college project, I am trying to create a windows service for screen capturing in order to record the activity of a user. I am working with SharpDX.Direct3D11.dll (https://github.com/sharpdx/SharpDX/blob/ab36f12303e24aa60fe804866617716b6ded95db/Source/SharpDX.Direct3D10/Device.cs#L69). For my project I was inspired as well by the ScreenToGif application developed by Nicke manarin (https://github.com/NickeManarin/ScreenToGif).

My custom program seems to work fine only if I start it in a console mode, but when I move all the logic inside a windows service, it fails with the following error:

"Error on prepare new capture:Could not find a proper output device for the area of L: 0, T: 0, Width: 1024, Height: 768"

I am thinking that this library only works if there is a display or window related to the application but as a windows service does not have any output window, the capture function fail.

Has anyone faced similar issue? or probably is there anyone who can provide a guidance or ideas on how to overcome this impediment and allow to take screen captures from a windows service?

thanks 2 all.

vhakti
  • 369
  • 1
  • 2
  • 11
  • Windows Services (WS) do not by default have the ability to interact with the user (e.g. display a GUI). This is not surprising as they can run before any user has logged in. It is a common trap to develop a WS as a non-WS (console app) only converting it to a WS at the very end where developers are surprised to find it may not work. Apart from not having a GUI, they run in a different security context and may not have access to the entirety of the filesystem or network as the developing user. Always best to test a WS project regularly –  Dec 02 '20 at 00:51
  • ...you might want to consider creating a regular app but just make it invisible to the user. –  Dec 02 '20 at 00:59
  • Thank you @MickyD ..you mean that it is feasible that I can keep using the console app I already developed but make it invisible to the user? – vhakti Dec 02 '20 at 14:59
  • Yes indeed, check out [this](https://stackoverflow.com/a/3497671/585968) –  Dec 02 '20 at 21:31

0 Answers0