Jump to content

Recommended Posts

Posted

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:

post-158212-1198990160_thumb.jpg

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 crashes

keys required for it to run properly:

ribbons.reg

heres 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 to
an 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)


Posted (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 crashes

In 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 by Glenn9999
Posted

got it

RibbonWidth = (int)RibbonsKey.GetValue("RibbonWidth");

should have been

RibbonWidth = (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 4

post-158212-1199057614_thumb.jpg

Aurora.exe

post-158212-1199057625_thumb.jpg

Bubbles.exe

post-158212-1199057632_thumb.jpg

Mystify.exe

post-158212-1199057640_thumb.jpg

Ribbons.exe

if only there was a way to actually build them into the screensavers control panel

but either way they work great

Posted
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... :wacko:

Posted (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... :wacko:

(Description of an attempt to run the compiler deleted. Below is much better.)

Edited by Glenn9999
Posted

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 :)

Posted

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). :wacko: I ended up using Notepad++.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...