Я не нашел это прежде, но из любого приложения Вы можете сцепление SessionSwitchEventHandler. Очевидно, Ваше приложение должно будет работать, но пока это:
Microsoft.Win32.SystemEvents.SessionSwitch += new Microsoft.Win32.SessionSwitchEventHandler(SystemEvents_SessionSwitch);
void SystemEvents_SessionSwitch(object sender, Microsoft.Win32.SessionSwitchEventArgs e)
{
if (e.Reason == SessionSwitchReason.SessionLock)
{
//I left my desk
}
else if (e.Reason == SessionSwitchReason.SessionUnlock)
{
//I returned to my desk
}
}
What you need to do is change the Deployment Target setting in your project. The Deployment Target specifies the minimum OS you would like your application to run on. This is regardless of the SDK you build against, which should always be the most recent SDK so you can ensure your application runs correctly on the most recent OS version available. So, in short:
To answer your second question, if you set the Deployment Target to 3.0 your 3.1-only code will no longer compile. There are workarounds to that problem, however.