Say, I have a Windows service application and also windowed client applications running in each logged on user session. If I call RegisterWindowMessage in each client app and try to trap that message there. And then also call RegisterWindowMessage with the same message name in the service app and then use it in a call to SendNotifyMessage again from the service to notify each client app of a single-fire event, will that work?
PS. I program using C++/MFC and native WinAPIs.
If your service application is running under the system account it cannot send messages to the user account's application.
Your can try the following approach:
Go through all the sessions (WTSEnumerateSessions) to get all
WindowStation,
Open these stations (OpenWindowStation),
Per station
Associate your process with the station (SetProcessWindowStation),
Go through all station desktops (Enumdesktops),
Go through all windows (EnumdesktopWindows) until your found one of your
application's window
You probably will have issues with UAC though.
Related
Im developing a software and im considering it as a Service because i need it to listen to ports 24X7 and notify when new client got connected(Toast Notification). I was able to send Toast notification from classic Win32 c++ application but i can't send it through Windows Service even when i check 'Allow Service to Interact with UI'. What do you think about the software Architecture?! Do you think i should reconsider the software Architecture or there is any other way to send Toast notification through Windows Service?!
"Allow Service to Interact with UI" only has an effect until XP. Up to then, the first user logged in runs in Session 0, the same Session that services run in. But from Vista onwards, Session 0 is now isolated, users run in Session 1 and higher only, so services can no longer interact with users.
When you want your service to display a toast, have the service use CreateProcessAsUser() to spawn a separate process in an available user Session (plenty of examples floating around demonstrating how to do that), and then that process can display the toast as needed.
I am creating a mini-filter driver. In that i communicate with user mode application to get the some of the data form user. i communicate with user mode using "communication port". i tried to communicate with user mode application it worked fine.
One the suggestion i got form others is to use windows service to fetch the data since it will always be running and we want user mode application to run always.
My question is
1) Can i create "communication port" in windows service?
2) If i create windows service, how to get specific user information. i mean, when i send the request to service how service come to know from which user session data needs to be fetched?
3) which one is better, i mean user mode or windows service is better solution.
1) Can i create "communication port" in windows service?
Yes you can create it in service.
2) If i create windows service, how to get specific user information. i mean, when i send the request to service how service come to know from which user session data needs to be fetched?
Service does runs under system account and not under any logged in user. So to show popup or dialog to current logged in user, you can look at WTSGetActiveConsoleSessionId() or similar api to get console session.
3) which one is better, i mean user mode or windows service is better solution.
Depends upon your design. As you mentioned service is always running to if your driver depends upon such requirement then do with service. But it will take more efforts to actually interact with user.
But if your driver can work without any service/app connection as such then go with application.
I need to create simple web service application. I need to show message box on the pc that runs that service. Is it possible to ask web service to create message box?
No, thats Not possible. But you can create a client application, which consumes that service. Check the condition and display the message box.
We have developed a network based C++ application that should run as a service for Windows XP, 7 32-bit system.
The application is console based.
User should be able to see the logs in console once the app is up and running.
To make application run as a service , we used XYNTService
The application is working as a service and it works fine under XP.
But I am not able to see the console under Windows 7, Since the service is running under the local SERVICE account, probably we can not see the GUI or access it in any way, because it is running in another winlogon session.
So can some one please suggest how can we make the service interactive so that user can see logs on the console while the app is running as a service?
Else
What if I make it a tray based application, is there a way to redirect logs a window?
Actually you can subscribe to logon/logoff events and then use WTSEnumerateSessions with CreateProcessAsUser to create GUI each time user logs into system, however it's not a good choice.
Making a tray app that automatically runs when user logs into system is better idea, you can use any of IPC mechanisms (named pipes, shared memory, sockets) to sent logs from service to tray app.
I need to capture the Skype Event through Windows Service.Skype like Call etc.
I am trying to register the Skype Notification but it failing.
Whether Windows Service allows Registering Skype Event or not?If not how can we achieve this.
Windows service in general allows to register events from Skype but first you must define:
1) Are you going to use Skype4COM (Desktop API) to communicate with one of standard Skype clients.
2) OR are you going to build your own Skype client using SkypeKit SDK?
The case 1 allows exchanging data only if some Skype client is running
but case 2 can work even while no user is logged in but it requires much more effort.
it is not possible to have Skype4COM in windows service