问题描述
我有一个MDI应用程序.该MDI应用程序还有许多其他工具,包括编辑器.我想用我的MDI应用程序的编辑器打开所有".txt"文件,从而使我的应用程序成为所有".txt"文件的默认查看器.
I have a MDI application. This MDI application has lots of other tools including an editor as well. I would like to open all the ".txt" files with the editor of my MDI application, thereby making my application as the default viewer of all the ".txt" files.
无论何时用户编辑".txt"文件,MDI应用程序都应启动,并在编辑器窗口中填充所选".txt"文件的内容.
Whenever the user edits a ".txt" File the MDI application should launch and a editor window should be populated with the contents of the chosen ".txt" file .
请问有什么方法可以做到这一点.
Is there a way I can do that please.
谢谢
推荐答案
您需要更改此注册表项:
You need to change this reg key:
HKCR\txtfile\shell\open\command
将默认值更改为您的程序,并在参数末尾添加%1.然后在程序中处理命令行args,以执行所需的操作.
Change the default value to your program with %1 at the end for parameters. Then in your program handle the command line args to do what you want with it.
这篇关于如何在C#中设置文件类型关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!