如何设置从自定义文件类型到程序的文件关联 [英] How can I set a file association from a custom file type to a program

查看:94
本文介绍了如何设置从自定义文件类型到程序的文件关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我创建了一个自定义文件,该文件实际上与我的程序可以读取的文件名为"Bacon.dek".我通常可以从程序中访问,修改它,等等,只有几个问题仍然存在(也可以以相对正确的速度修复它们).

现在,我想做的(并在完成后尝试尽快修复)实际上是从Windows资源管理器中选择我的文件,右键单击它,然后选择打开方式...",然后选择我的应用程序. /p>

还是只是将我的应用程序设置为默认应用程序,只需双击它,它就会在我的应用程序中打开?像我双击"Bacon.dek",然后打开"Eggs.exe",读"Bacon.dek"?

解决方案

基本上,您必须这样做-

在注册表中添加这些键

[HKEY_CURRENT_USER\Software\Classes\dekEditor\shell\open\command]<br/>
@="c:\path\to\app.exe \"%1\""<br/>
[HKEY_CURRENT_USER\Software\Classes\.dek]<br/>
@="dekEditor"<br/>

这是一个两步任务.首先,将扩展名.dek与dekEditor(第二个条目)相关联,然后在Classes(第一个条目)中指定它.

答案取自:创建注册表项以将文件扩展名与C ++中的应用程序关联

MSDN文章.

>

Let's say I make a custom file that actually corresponds to what my program can read called "Bacon.dek". I can access it, modify it, etc. normally from my program, with only a few problems staying alive (fixing them at a relatively correct speed, too).

Now, what I wanna do (and try to fix rather quickly once done), is actually choosing my file from Windows Explorer, right-clicking on it, and choose "Open with..." and choose my application.

Or simply set my application as the default application to simply double-click it and it would open in my app? Like, I double-click "Bacon.dek", and it opens "Eggs.exe", reading "Bacon.dek"?

解决方案

Basically you have to do this -

In registry add these keys

[HKEY_CURRENT_USER\Software\Classes\dekEditor\shell\open\command]<br/>
@="c:\path\to\app.exe \"%1\""<br/>
[HKEY_CURRENT_USER\Software\Classes\.dek]<br/>
@="dekEditor"<br/>

This is a 2 step task.First you associate your extension .dek with dekEditor (2nd entry) and then specify it in Classes(1st entry).

Answer taken from: Create registry entry to associate file extension with application in C++

MSDN Article.

这篇关于如何设置从自定义文件类型到程序的文件关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆