且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何设置从自定义文件类型到程序的文件关联

更新时间:2023-02-08 19:06:42

基本上,您必须这样做-

在注册表中添加这些键

[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.