User Interactive Service in Windows 7 - c++

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.

Related

Toast Notification in Windows Service Win10

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.

Mini Filter driver communication with windows service

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.

AppHarbor: Communication between Web App and Background Worker

I have two questions, but let me set the stage first:
Say you have a typical scenario where you have a web application and a mid-tier web service.
The web application receives a request from the user, queries the web service and sends a response to the user.
If the web service and the web application were running on the same machine, the web app would go through localhost:port to access the web service.
(I do understand that AppHarbor web and background workers are not running on traditional machines but it's easier to use that metaphor)
To make this slightly complex, the web service is actually a console app running a HTTP server and thus acting as a web service, let's call it webservice.exe.
My first question is: will AppHarbor run webservice.exe on the same machine as the web application and so enable the web application to access the web service via localhost:port.
If not, will the machine name where the console app is running always be static (which allows web app to reliably access machinename:port). If so, will the webservice.exe machine allow incoming connections from the web application machine?
My second question is if both apps run on the same machine (the localhost scenario), will external users be able to access webservice.exe via myapp.apphb.com:port ?
Thanks!!
AppHarbor does not currently support background workers (which is where your console application would be running) attaching to ports.
If you instead decide to host the service in an ASP.NET application and run it in a web worker on AppHarbor (as a normal web site), then it would be available at myawesomeapplication.apphb.com or using a custom hostname if you decide to add one.
If the service-abstraction is not needed, you might also want to just do away with it and fold it into the main web site.

Does SendNotifyMessage API work across user sessions?

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.

attaching windows service to skype Public Api

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