开发者

How can I associate a specific file extension with my application?

How can I associate a specific extension with my .NET application so that the user can open a file with that extension by just double-clicking it?

I have seen some questions and some answers on these topic, but nothing seems to be complete and going to the point.

My questions is:

What is the best strategy to associate a specific extension with an applicatio开发者_如何转开发n? What are the necessary steps / tools to do so? How to include this in a setup deployment project?

Thanks


  1. Open RegEdit.exe
  2. Under HKEY_CLASSES_ROOT, create a new key called '.xxx' (xxx is your extension name). Change the default value to "xxxfile" (this is the name of file type, you can change it as you like)
  3. Under HKEY_CLASSES_ROOT, create a new key called 'xxxfile'.
  4. Under xxxfile, create a key called 'shell'.
  5. Under shell, create a key called 'open'.
  6. Under open, create a key called 'command'. Change the default value to '"C:\Program Files\AnyProgram\AnyProgram.exe" "%1"' (change to the program which you want to open the file)

After this, you will be able to open the extension with your preferred program.

If you want to do this in a setup deployment, then you just need to use the cmd to modify the registry info.

Hope this will help you.


Read Hans Passant comment. Using direclty Setup Deployment Project and defining there file associations is quick and easy. Perfect.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜