Wish there was an equivalent .NET library reference though. The MSDN library is very thorough but also bloated and slow. Kinda typical of Microsoft when you think about it. Heh, heh.
To celebrate, here's the first useful program I wrote (just now) in C#: ToggleScreenSaver. It's a command-line tool that turns your screen saver on or off. Works only on Windows. Usage is:
ToggleScreenSaver [on|off]
on: turns the screen saver on
off: turns it off
Source code:
// ToggleScreenSaver.cs
using System;
using Microsoft.Win32;
public class ToggleScreenSaver {
static void Main(string[] args) {
// args[0] is the first argument passed and so on, not the name of the program
// That's a little brain-dead, but OK, we can roll with it
RegistryKey rk = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", true);
if (args[0] == "on") {
rk.SetValue("ScreenSaveActive", "1");
} else {
rk.SetValue("ScreenSaveActive", "0");
}
rk.Close();
}
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.