How to change filetype association in the registry?

后端 未结 4 572
眼角桃花
眼角桃花 2020-12-01 14:56

first time posting in StackOverflow. :D I need my software to add a couple of things in the registry.

My program will use

Process.Star

4条回答
  •  自闭症患者
    2020-12-01 15:40

    If you are planning on providing an installer for your application, simply use the file association feature available in whatever installer framework you choose to use - even the Visual Studio setup project knows how to do this.

    To alter file type associations directly from your code, I believe you have to look into HKEY_CLASSES_ROOT and find/create a key with the extension you want to bind to (ie ".pdf"). Within this key, the default value is a string containing a reference to another key within HKEY_CLASSES_ROOT. Go follow that pointer, expand/create the shell subkey and add/change your commands here. Look around this area with regedit to get the fealing of how it looks.

    I have some C# code in a pet project of mine, which looks up the binding for PDF files and adds an extra option to their context menus. Feel free to have a look.

提交回复
热议问题