Jump to content
  • Advertisement
Sign in to follow this  
Prune

Send message to a service process

This topic is 2776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been using events to communicate between my app and my watchdog service, but after I noticed some crash events in the app can sometimes cause it to corrupt the log file, I decided to have it also send error logs to the service which would write them out in case the app crashes.

Except I don't know how to send a string to a service. I only see how to send it control codes, but not data. I couldn't figure out how to use WM_COPYDATA even if I make the service impersonate the user account (which I already do to access the user's registry). What do? I thought of creating a hidden window to get an HWND but I don't even know if that would work, so I didn't want to put in the time before asking...

Share this post


Link to post
Share on other sites
Advertisement
One way would be to just send it through the message pump.

MSDN - SendMessge

You could just send the message using the HWND_BROADCAST. See the remarks section about creating messages for inter-application communication.

[edit]
Instead you might use MSDN - PostMessage as it doesn't wait for the function call to return, if you don't want any kind of acknowledgement.

Share this post


Link to post
Share on other sites
While I've never tried it, the documentation would seem to suggest that it is possible (at least in a similar fashion as I described), because the message pump can receive messages that are just for the thread, not for any particular window.

From the MSDN -
Quote:

MSG structure
Members

hwnd
Type: HWND

A handle to the window whose window procedure receives the message. This member is NULL when the message is a thread message.


So while I'm not guaranteeing that SendMessage/PostMessage are the correct method of sending the message (MSDN - BroadcastSystemMessageEx or MSDN - PostThreadMessage looks like they might be candidates as well), I don't see any reason why it can't receive a message, just because it doesn't have a window handle.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!