Communicatng with an NT Service from a desktop application

Hello Experts,
I have a little problem. When an NT service is running in the background of NT (not interacting with the desktop) I can send messages to it because the FindWindow function doesn't find the window when called from the desktop. Any ideas how to send such messages or how to use the FindWindow correctly? I'm convinced there must be some way. Thank you, I hope you know more than me.
jakubklosAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

okhomaCommented:
May be the best way to communicate with NT service is using pipes. This is fast and easy, and you don't have to switch Window Station to send messages.
0
MadshiCommented:
Here are some possibilites:

(1) Use named pipes (already suggested by okhoma) - CreatePipe
(2) Use memory mapped files (CreateFileMapping + MapViewOfFile) and events (CreateEvent, SetEvent, WaitForSingleObject)

But you can also keep with the current solution (by using a window and PostMessage/SendMessage). Then the problem is simply how can your main app know that window handle of the service? Easy:

(1) Your service could write it's window handle temporarily to the registry
(2) Use a create memory mapped file (CreateFileMapping + MapViewOfFile) and put the window handle there

If you need more explanation (or some code) about one of the suggestions, please ask.

Regards, Madshi.
0
MadshiCommented:
P.S: You can also try to use OpenWindowStation, OpenDesktop and EnumDesktopWindows to find that window handle.
0
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

jakubklosAuthor Commented:
I see. I reckon the most professional way would be the pipes. However, I don't have any experience with that. Could you please, show me a piece of such code? Thank you guys.
0
MadshiCommented:
Here is an example source about how to use pipes:

http://www.jgsoftware.com/files/pipes.zip
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jakubklosAuthor Commented:
Cool. That's it :). Thanks Madshi.

Jake
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.