PC_LOAD_LETTER Posted December 30, 2007 Posted December 30, 2007 I got tired of fiddling with the registry to tweak out the Vista Screensavers and ive been meaning to try my hand at C#. This thread is the result of that attempt. Ive clipped together various code snippets from around the web and this is what i came up with:The actual utility:scr.exe (no source yet -its embarrassing bad)Heres the problem. the utility works perfectly if you already have the settings in the registry but if the keys dont exist before you run it, it crasheskeys required for it to run properly:ribbons.regheres the code clipping of where i get the data from the registry RegistryKey RibbonsKey = Registry.CurrentUser; RibbonsKey = RibbonsKey.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Screensavers\\Ribbons", true); RibbonWidth = (int) RibbonsKey.GetValue("RibbonWidth"); Console.WriteLine("RibbonWidth = " + RibbonWidth);as far as i can tell its failing at line 3 in that code when it tries to ready the data inside a nonexistent key. how can i make it ignore the error or restructure the code to prevent it.Unhandled Exception: System.NullReferenceException: Object reference not set toan instance of an object. at ScrForm..ctor() at Test.Main()also, can I get a decent IDE for free? (no warez) textpad + command line is getting tiresome. P.S. I know TweakVista can already do this. I refuse to pay for a skinned regtweaker. Plus this is good way to learn (I hate making useless 'Hello World' apps)
Glenn9999 Posted December 30, 2007 Posted December 30, 2007 (edited) also, can I get a decent IDE for free? (no warez) textpad + command line is getting tiresome.Notepad++ Ask if you need any help on configuring it (the language pre-sets are okay, but setting up the compiler to run from it is not so obvious).Heres the problem. the utility works perfectly if you already have the settings in the registry but if the keys dont exist before you run it, it crashesIn your code you'll need to check for that. Something like "try to read these registry entries, if they do not exist then create them."as far as i can tell its failing at line 3 in that code when it tries to ready the data inside a nonexistent key. how can i make it ignore the error or restructure the code to prevent it.Or a non-existent key path if you did not create that first. In either event, there should be an exception condition triggered which you should be able to test for. Edited December 30, 2007 by Glenn9999
PC_LOAD_LETTER Posted December 30, 2007 Author Posted December 30, 2007 got it RibbonWidth = (int)RibbonsKey.GetValue("RibbonWidth");should have beenRibbonWidth = (int)RibbonsKey.GetValue("RibbonWidth", 1030000000);because if it failed the data type wasnt int so therefore would fit where i was trying to put it.it now works 100% and i went ahead and made all 4Aurora.exeBubbles.exeMystify.exeRibbons.exeif only there was a way to actually build them into the screensavers control panelbut either way they work great
gamehead200 Posted December 31, 2007 Posted December 31, 2007 Notepad++ Ask if you need any help on configuring it (the language pre-sets are okay, but setting up the compiler to run from it is not so obvious).Holy crap, you can do that!? This would have saved me so much time during my last semester...
Glenn9999 Posted December 31, 2007 Posted December 31, 2007 (edited) Notepad++ Ask if you need any help on configuring it (the language pre-sets are okay, but setting up the compiler to run from it is not so obvious).Holy crap, you can do that!? This would have saved me so much time during my last semester... (Description of an attempt to run the compiler deleted. Below is much better.) Edited December 31, 2007 by Glenn9999
Glenn9999 Posted December 31, 2007 Posted December 31, 2007 Nevermind the above post...got it figured out.I got the compiler thing figured out to my satisfaction. Actually I missed something in Notepad++. There's a plugin called NPPEXEC which allows batch scripting, and has an output console. So you can get it so it literally works like an IDE.Hit F6 and you'll get a console where you can type commands and things. For the compiler I was trying to run earlier, the following works:npp_save"c:\program files\borland\delphi 3\bin\dcc32" "$(FULL_CURRENT_PATH)"The second-line is as before (runs the compiler, full_current_path is the currently loaded file). npp_save is a nppexec script command which saves the current file to disk.Save this to a script name, then when you pull up Notepad++, you can hit F6 and then select the script name, and then hit ENTER. Subsequent compiles only require F6 then ENTER. Of course, you can have multiple scripts if you have multiple compilers. The scripts are saved in plugins\config.Can't get much better than this
gamehead200 Posted January 1, 2008 Posted January 1, 2008 Wow, like I said, that would've come in real handy during my last semester. We were told to either use Notepad++ and the command line compiler or Visual Studio (provided to us by MSDN-AA). I ended up using Notepad++.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now