我有一个 MDI 应用程序。该 MDI 应用程序还有许多其他工具,包括编辑器。我想使用 MDI 应用程序的编辑器打开所有“.txt”文件,从而使我的应用程序成为所有“.txt”文件的默认查看器。
每当用户编辑“.txt”文件时,MDI 应用程序都应启动,并且编辑器窗口应填充所选“.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.
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.
Thanks
发布评论
评论(3)
在我的应用程序中,我在启动时执行此操作:
当然,将所有路径、名称和扩展名更改为您的应用程序。
不过,请务必小心弄乱用户的 .txt 文件关联。我在每次启动时检查分配,因为我的应用程序使用自定义类型并且仅部署在内部映像系统上。我不知道您的应用程序部署在哪里,但如果我从互联网上下载的某些随机实用程序不断更改我的 .txt 文件关联,我会非常恼火,而且我相信很多其他人也会如此。
In my application, I do this at launch:
With all paths, names, and extensions changed to your application, of course.
Do be careful with messing with the user's .txt file association, though. I check the assignment on every launch because my application is using a custom type and is only deployed on in-house imaged systems. I don't know where your application is being deployed, but I would be very annoyed if some random utility I downloaded from the internet was constantly changing my .txt file association, and I'm sure a lot of other people would be too.
您需要更改此注册表项:
将参数的默认值更改为程序末尾的%1。然后在您的程序中处理命令行参数以执行您想要的操作。
You need to change this reg key:
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.
文件关联可以通过编程方式完成,例如 这个或者可以通过像此
File assocition can programmatically be done like this or it can be done by through registry key like this