Search Forum
(53671 Postings)
Search Site/Articles

Archived Articles
712 Articles

C# Books
C# Consultants
What Is C#?
Download Compiler
Code Archive
Archived Articles
Advertise
Contribute
C# Jobs
Beginners Tutorial
C# Contractors
C# Consulting
Links
C# Manual
Contact Us
Legal

GoDiagram for .NET from Northwoods Software www.nwoods.com


 
Printable Version

Very Simple Shell Ext
By Michelangelo Giacomelli

How to add a "open with my prog" voice in context menu. ("shell menu ext"), this feature is usefull when we make same program and we want register same extension to it.

// project created on 24/08/2002 at 22.05
using System;
using Microsoft.Win32;

class AddShellCommand
{
  public static void Main(string[] args)
  {
    RegistryKey newkey;
    newkey = Registry.ClassesRoot.CreateSubKey("myprog_file");
    newkey = newkey.CreateSubKey("shell");
    newkey = newkey.CreateSubKey("Open with myprog");
    newkey = newkey.CreateSubKey("command");
    newkey.SetValue ("", "c:\myfolder\myprog.exe %1");
    newkey = Registry.ClassesRoot.CreateSubKey(".myext");
    newkey.SetValue ("", "myprog_file");
  }
}