I have a service that runs and I\'d like to receive notification when:
a) the network is connected.
b) when a user logs in to the machine.
How can I do
To find out when the network is connected, add a handler for the NetworkAvailabilityChanged
in the System.Net.NetworkInformation.NetworkChange
class.
One simple way to find out when a user logs in is to make a separate exe and put it into common startup. It would be executed whenever any user logs in, and could then communicate with your service and give the username. If you want your service to interact with the user's desktop, this is (I believe) the only way to do it. If you don't however, this might not be a good idea.
Remember that it is possible for multiple users to be logged in at once, especially through Remote Desktop or Terminal Services (On Windows Server)