Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi

I have written a .net html editor and want to check in form_load if it is the default html editor. how should I do it via .net 2?

also how can I add an item to the context menu of windows explorer named "edit with my html editor"?

thanks.

  • Administrators
Posted

The only way I know of doing this is via the registry;

 

If you look under the HKEY_CLASSES_ROOT key you should see an entry for .html - this will have as it's default value something like htmlfile. If you then look under HKEY_CLASSES_ROOT\htmlfile\shell\edit\command then you will see the currently registered application.

 

To make your application the default simply change this to point to your app (this is pretty easy to do via the registry classes under .Net)

 

Personally I would make this an option within your program rather than resetting it every time your application is run as the user might prefer another tool and choose your application for a feature that it excels in - if running the app causes it to take over the association I would soon stop using it.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Thanks, it was great!

Just one problem:

I use this code to get data from registry:

My.Computer.Registry.ClassesRoot.OpenSubKey("htmlfile\shell\Edit\command").GetValue("").ToString

But when I use this code to save data to registry:

       Dim MyKey As RegistryKey = Registry.CurrentUser.OpenSubKey("htmlfile\shell\Edit\command")
       MyKey.SetValue("", My.Application.Info.DirectoryPath + "\MyEditor.exe")

I get error: Object reference not set to an instance of an object.

Please see attachment, it does not have a name! What should I do? :confused:

  • Leaders
Posted

You are getting the error because you are opening the CurrentUser hive instead of ClassesRoot when you are saving the setting. If a key does not exist then a null reference is returned instead of an exception being thrown.

 

Also, not only should you make this an option, but don't be surprised if an exception is thrown when the code is run on a limited user account.

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...