Grzenio
Grzenio

Reputation: 36639

GetDesktopWindow alternative when running as service

I am trying to test my WinForm app as part of the build (which runs as a service). I am using GetDesktopWindow and EnumChildWindows to find the controls I am interested in. This works perfectly when I run it in interactive session from the console, debugger, etc. but fails to find any control when run as part of the build. What can I use as an alternative to find all windows when running as a service?

Upvotes: 0

Views: 1947

Answers (2)

Mattias S
Mattias S

Reputation: 4798

Sounds like you could (if you have the appropriate access rights) use EnumDesktopWindows on the default interactive desktop.

Upvotes: 0

1800 INFORMATION
1800 INFORMATION

Reputation: 135245

Typically windows services are not allowed to interact with the desktop at all (not since the introduction of windows Vista) - have you considered changing your build process to run as a scheduled task? Why are you using GetDesktopWindow anyway? It sounds like you are trying to do something odd here, if you are trying to enumerate all of the desktop windows to find your app.

Upvotes: 1

Related Questions