我如何通过vc ++源代码在HKEY_CLASSES_ROOT中注册我的文件扩展名 [英] How can i register my file extension in HKEY_CLASSES_ROOT through vc++ source code

查看:96
本文介绍了我如何通过vc ++源代码在HKEY_CLASSES_ROOT中注册我的文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了自己的文件扩展名 .sos ,并手动将其注册在 HKEY_CLASSES_ROOT 中.

但是
我如何注册&使用vc ++代码取消注册?

指导我实施代码.






在此先感谢您.



I created my own file extension .sos and i registered it in HKEY_CLASSES_ROOT manually .It is working.

But
How can i register & unregister it using vc++ code?

guide me to implement the code.






Thanks in advance.

推荐答案

您说过,当您手动注册扩展程序时,它可以工作,那么您必须知道要编写哪些键.它无法在代码中正常工作,也许您的应用程序没有写那些注册表项的特权.
You said when you manually register your extension it works, then you must know what keys to write. It it not working in code, maybe your app does not have privileges to write to those registry keys.


需要设置许多项才能使其正常工作.

HKEY_CLASSES_ROOT中为此文件扩展名字符串(包括前导点字符)创建一个新密钥,并将其默认值设置为唯一的名称,您可以使用该名称将二者链接在一起.这将提供以下键和值:
There are a number of keys that need to be set in order for this to work.

Create a new key in HKEY_CLASSES_ROOT for this file extension string (including the leading dot character) and set its default value to a unique name that you can use to link the two together. This will give the following key and value:
HKEY_CLASSES_ROOT\.ext
Default extfile


创建一个子项OpenWithList\application.exe,其中application.exe是将处理具有此扩展名的文件的应用程序的名称.现在,您有了密钥:


Create a subkey OpenWithList\application.exe where application.exe is the name of the application that will handle files with this extension. You now have the key:

HKEY_CLASSES_ROOT\.ext\OpenWithList\application.exe


创建一个与HKEY_CLASSES_ROOT\.ext密钥中的默认值相同名称的密钥,并将缺省值设置为OpenWithList\application.exe中使用的应用程序的未经修饰的名称,并提供密钥和值:


Create a key with the same name as the default value in the HKEY_CLASSES_ROOT\.ext key and set its default value to the unadorned name of the application as used in OpenWithList\application.exe, giving the key and value:

HKEY_CLASSES_ROOT\extfile
Default application file


如下所示,在HKEY_CLASSES_ROOT中的应用程序"项中添加一个子项,并将其默认值设置为应用程序的完整路径,并在单击时在文件名后添加占位符,因此:


Add a subkey to the Applications key in HKEY_CLASSES_ROOT as follows, and set its default value to the full path of your application followed by a placeholder for the filename when you click on it, thus:

HKEY_CLASSES_ROOT\Applications\application.exe\shell\open\command
Default C:\Program Files\Utilities\application.exe %1


因此,在extfile键上添加一个类似的子键:


Add a similar subkey to the extfile key thus:

HKEY_CLASSES_ROOT\extfile\shell\open\command
Default C:\Program Files\Utilities\application.exe %1


请注意如何将扩展名,扩展类型"名称和程序名称链接在一起,以使其起作用.


Note how the extension, the "extension type" name and the program name are linked in order for this to work.


这篇关于我如何通过vc ++源代码在HKEY_CLASSES_ROOT中注册我的文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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