Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 183
  • Last Modified:

SendMessage() doesn't work from DLL and service

Hi All,

I want to send a message to my app when some event happened
in the service. The problem is that SendMessage doesn't work.
When I try to send message from another app to my app it worked.

Has anybody any guess?

Thanks in advance

Andras
0
bandi081497
Asked:
bandi081497
  • 3
  • 2
1 Solution
 
d003303Commented:
Yo,
is your service allowed to interact with the desktop ? If not, it resists on a seperate, invisible window station where the window handle you are using is invalid.

Slash/d003303
0
 
bandi081497Author Commented:
How can I set that? I mean the service would be allowed to intereact with the desktop?
Anyway, I've tried to send message from a DLL which is called
from service. I think that could be the problem, doesn't it?

Andras
0
 
d003303Commented:
Yes, the DLL is running in the same process environment as the service. To allow interaction with the desktop, proceeed as follows:
In Control Panel, open Services. Select your service in the listbox and click on Startup. Select Allow Service To Interact With Desktop there.

Slash/d003303
0
 
bandi081497Author Commented:
Thanks the right solution. I've tried and it worked.
But can you help me how can I set this
 
Allow Service To Interact With Desktop

from software when the service is being installed?

Thanks in advance

Andras
0
 
d003303Commented:
Yo,
use the CreateService API call. Set the dwServiceType parameter to
(SERVICE_WIN32_OWN_PROCESS or SERVICE_INTERACTIVE_PROCESS)

Slash/d003303
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now