Showing posts with label c#. Show all posts
Showing posts with label c#. Show all posts

Monday, December 7, 2009

Vista: Programmatically Adding the 'Run' Command to the Start Menu

For a user, adding the 'run' command to the start menu is easy process. However, developers need a way to automate this process. Thankfully, there is a single registry entry that will add the run command to the vista start menu for all users.

HKLM\Software\Microsoft\CurrentVersion\explorer\Advanced. Change the value of "Start_ShowRun" to "1". If it doesn't exist, create the value name and set the value to "1". Voila!

For the C# developers (formatting courtesy of Manoli.net)


   1:  //Add run command to Start menu
   2:  RegistryKey runKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\explorer\Advanced", true);
   3:  runKey.SetValue("Start_ShowRun", 1, RegistryValueKind.DWord);

Friday, November 20, 2009

C# Project: DosTweet

I wanted to create a simple, console (DOS) based Twitter client. It turns out it has already been done (Quitter). But that didn't stop me from trying it anyways.

I started with the twitterizer library as a foundation. It was all straightforward but having worked primarily with windows forms applications, I found subtle nuisances in working with console applications. I used a switch based text menu and the twitterizer library has an extensive set of methods for interfacing with Twitter's API.

Some helpful twitterizer examples:

I put the executable and source code online at Google Code here. Keep in mind, this is meant to be a simple, console based twitter client: it retrieves your friends' timeline and allows you to post a tweet. As time continues, I will release updated versions.

As always, I realize there a large number of different ways to achieve the same effect. This is provided as a point of reference only.

Monday, November 16, 2009

C#: Extracting image resources

I've been working with C# for a number of months now. I often have to extract resources in the programs I've been writing and felt I had a good handle on it. However, last night I need to extract a simple image resource but found my normal method of extracting using a byte array simply wasn't working.

After a bit of experimenting, I stumbled upon the answer.
  1. Add your image as a resource (Check out this link for more info).
  2. Now to extract your image, use the following line:
    Properties.Resources.ImageName.Save("FullPathAndNameOfImage.jpg");
NOTE: You don't have to extract as .jpg. You can extract as .PNG or GIF. The important part is you have to give a full path to extract the image to, as well as the file type.