Link to home
Start Free TrialLog in
Avatar of _corey_
_corey_

asked on

Using ::PostMessage and ::SendInput in a Service

To meet  the requirement for a project, I am using a windows service (made with VC6 using the old CComModule) that spawns a thread which simulates mouse events when certain conditions occur.

Now, this worked when the program was in Local Server mode and not doing any of the message handling/etc, but when I put it into Service mode and starte it, everything works right except for the mouse messages.  They don't seem to have any effect even though I receive no errors from the calls.

Any thoughts?
Avatar of Dexstar
Dexstar

_corey_:

> Now, this worked when the program was in Local Server mode and not doing any
> of the message handling/etc, but when I put it into Service mode and starte
> it, everything works right except for the mouse messages.  They don't seem to
> have any effect even though I receive no errors from the calls.

What account is the service using?  In order to interact with the desktop, it is going to have to be the system service account, and you have to have the "interact with desktop" option checked in the services control panel.

If that doesn't work, then it might not be possible to have an application (directly) post messages to another user's windows.  There are ways around it though, so let me know if what I already suggested doesn't work.  :)

Hope that helps,
Dex*
Avatar of _corey_

ASKER

The "interact with desktop" option performs perfectly for my needs.

I just never tried to send such messages from a service before and was not sure where to look, so this really helped not waste any time :)

However, I was looking for a programming method instead of a property(which I should have), but it seems to require re-setting this option everytime you register the Service.  How can I have it defaulted, let's say after a registration of the service?
ASKER CERTIFIED SOLUTION
Avatar of Dexstar
Dexstar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of _corey_

ASKER

Humble pie tastes good and speeds up productivity :) Thanks for the very quick help.  A few more points for the speed?
_corey_:

> Humble pie tastes good and speeds up productivity :) Thanks for the very quick
> help.  A few more points for the speed?

If you wanted to, I certainly wouldn't object!  :)

Dex*