如何正确地将文件关联添加到Windows注册表?

发布于 2024-09-11 20:36:03 字数 5155 浏览 3 评论 0原文

我应该将哪些数据添加到 Windows 注册表中以正确创建文件关联?

我问这个问题主要是因为我几年前编写的一些旧应用程序,它们使用 Visual Studio .NET 的 Windows Installer 打包程序来创建文件关联。我安装的扩展是 .whr.encxml

现在,在安装这些应用程序的计算机上,有时会出现一个奇怪的问题 - 当在 Google Chrome 或 Internet Explorer 中下载文件(尤其是 exe、msi 或 zip 文件)时,浏览器会会将文件扩展名更改为我的安装程序安装的扩展名之一。我不知道它是否会影响其他浏览器 - 这两个浏览器有什么共同点吗?所以...如果您下载,例如 http://example.com/downloads/application.exe< /a>,文件将下载为 http://example.com.downloads/application.encxml(或 .whr,无论当前选择哪个),没有任何明显的原因。

我应该注意,HKCR\.whrHCKR\.encxml 键引用的键(Account Manager 加密 XML 文件和工作时间记录)中包含空格,并且当我在 Visual Studio 中创建关联时,我没有添加“。”到前面。也许不允许使用空格,和/或者您应该添加前缀“.”?注册表代码似乎没问题,但通过查看注册表,我注意到每个其他应用程序都不使用关联类中的空格,而且安装在我所知道的任何计算机上的任何应用程序的任何其他文件扩展名也不会发生此问题 - 仅由我的应用程序的 VS 安装程序创建的。我粘贴了与文件扩展名相关的相应注册表项和值的注册表转储 - 由于 MSI 是专有的,我不知道这是否是全部,但从我从其他应用程序中了解到的情况来看,这应该是一切。多年来我一直想知道这个问题,但始终无法弄清楚。我很快就会用新产品替换其中一个旧应用程序,所以这次我想确保不存在像这样的奇怪错误...

这是数据(请注意,我已经用以下命令指示了一些二进制字符串的文本值) // 值下方的注释):

[HKEY_CLASSES_ROOT\.encxml]
"Content Type"="application/octet-stream"
@="Account Manager Encrypted XML File"

[HKEY_CLASSES_ROOT\.encxml\Account Manager Encrypted XML File]

[HKEY_CLASSES_ROOT\.encxml\Account Manager Encrypted XML File\ShellNew]

[HKEY_CLASSES_ROOT\Account Manager Encrypted XML File]
@="Account Manager Encrypted XML File"

[HKEY_CLASSES_ROOT\Account Manager Encrypted XML File\DefaultIcon]
@=hex(2):25,00,41,00,50,00,50,00,44,00,41,00,54,00,41,00,25,00,5c,00,4d,00,69,\
  00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,5c,00,49,00,6e,00,73,00,74,00,\
  61,00,6c,00,6c,00,65,00,72,00,5c,00,7b,00,42,00,36,00,34,00,31,00,37,00,36,\
  00,30,00,42,00,2d,00,37,00,44,00,42,00,37,00,2d,00,34,00,46,00,31,00,42,00,\
  2d,00,41,00,44,00,36,00,45,00,2d,00,30,00,41,00,33,00,34,00,32,00,30,00,46,\
  00,35,00,45,00,45,00,30,00,44,00,7d,00,5c,00,5f,00,36,00,46,00,45,00,46,00,\
  46,00,39,00,42,00,36,00,38,00,32,00,31,00,38,00,34,00,31,00,37,00,46,00,39,\
  00,38,00,46,00,35,00,34,00,39,00,2e,00,65,00,78,00,65,00,2c,00,30,00,00,00

// Product code GUID is: {F7F214E9-ED37-4AE1-B0D2-93427973E60A}, which is different from below but I probably changed it at some point for some reason
// %APPDATA%\Microsoft\Installer\{B641760B-7DB7-4F1B-AD6E-0A3420F5EE0D}\_6FEFF9B68218417F98F549.exe,0

[HKEY_CLASSES_ROOT\Account Manager Encrypted XML File\shell]
@="open"

[HKEY_CLASSES_ROOT\Account Manager Encrypted XML File\shell\open]
@="&Open"

[HKEY_CLASSES_ROOT\Account Manager Encrypted XML File\shell\open\command]
@="\"C:\\Program Files\\Petroules Enterprises\\Account Manager\\AccountManager.exe\" \"%1\""
"command"=hex(7):4c,00,29,00,25,00,59,00,63,00,73,00,67,00,2d,00,4c,00,41,00,\
  28,00,30,00,64,00,66,00,34,00,36,00,75,00,5f,00,50,00,27,00,3e,00,27,00,7d,\
  00,27,00,66,00,25,00,6f,00,59,00,64,00,4b,00,69,00,48,00,74,00,7a,00,35,00,\
  21,00,55,00,2b,00,6c,00,68,00,54,00,20,00,22,00,25,00,31,00,22,00,00,00,00,\
  00

// This is a bizarre-looking value... what's up with that?
// L)%Ycsg-LA(0df46u_P'>'}'f%oYdKiHtz5!U+lhT "%1"

[HKEY_CLASSES_ROOT\.whr]
"Content Type"="application/octet-stream"
@="Work Hours Record"

[HKEY_CLASSES_ROOT\.whr\Work Hours Record]

[HKEY_CLASSES_ROOT\.whr\Work Hours Record\ShellNew]

[HKEY_CLASSES_ROOT\Work Hours Record]
@="Work Hours Record"

[HKEY_CLASSES_ROOT\Work Hours Record\DefaultIcon]
@=hex(2):25,00,41,00,50,00,50,00,44,00,41,00,54,00,41,00,25,00,5c,00,4d,00,69,\
  00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,5c,00,49,00,6e,00,73,00,74,00,\
  61,00,6c,00,6c,00,65,00,72,00,5c,00,7b,00,46,00,41,00,32,00,33,00,44,00,37,\
  00,36,00,34,00,2d,00,46,00,36,00,34,00,39,00,2d,00,34,00,38,00,46,00,39,00,\
  2d,00,38,00,44,00,30,00,42,00,2d,00,45,00,31,00,38,00,38,00,35,00,41,00,39,\
  00,38,00,31,00,46,00,39,00,39,00,7d,00,5c,00,5f,00,36,00,46,00,45,00,46,00,\
  46,00,39,00,42,00,36,00,38,00,32,00,31,00,38,00,34,00,31,00,37,00,46,00,39,\
  00,38,00,46,00,35,00,34,00,39,00,2e,00,65,00,78,00,65,00,2c,00,30,00,00,00

// Product code GUID: {FA23D764-F649-48F9-8D0B-E1885A981F99}, same as below
// %APPDATA%\Microsoft\Installer\{FA23D764-F649-48F9-8D0B-E1885A981F99}\_6FEFF9B68218417F98F549.exe,0

[HKEY_CLASSES_ROOT\Work Hours Record\shell]

[HKEY_CLASSES_ROOT\Work Hours Record\shell\open]
@="&Open"

[HKEY_CLASSES_ROOT\Work Hours Record\shell\open\command]
@="\"C:\\Program Files\\Petroules Enterprises\\Work Hours Calculator\\WorkHoursCalculator.exe\" \"%1\""
"command"=hex(7):28,00,5d,00,56,00,49,00,79,00,55,00,7b,00,5e,00,4e,00,3f,00,\
  26,00,68,00,48,00,7e,00,53,00,24,00,6e,00,31,00,36,00,59,00,3e,00,33,00,75,\
  00,5f,00,7d,00,47,00,26,00,70,00,79,00,75,00,78,00,38,00,4e,00,72,00,43,00,\
  6e,00,67,00,27,00,44,00,67,00,42,00,20,00,22,00,25,00,31,00,22,00,00,00,00,\
  00

// Same bizarre-looking type of value as before, but different...
// (]VIyU{^N?&hH~S$n16Y>3u_}G&pyux8NrCng'DgB "%1"

What data and where, should I add to the Windows registry to properly create a file association?

I ask this question primarily because of some old applications that I wrote years ago, which used Visual Studio .NET's Windows Installer packager to create the file associations. The extensions I installed were .whr and .encxml.

Now, on the computer on which these applications are installed, a strange problem occurs sometimes - when a file is downloaded in either Google Chrome or Internet Explorer (especially an exe, msi or zip file), the browser will change the file extension to one of the extensions that was installed by my installer. I don't know if it affects other browsers - do those two have anything in common? So... if you download, for example, http://example.com/downloads/application.exe, the file will be downloaded as http://example.com.downloads/application.encxml (or .whr, whichever one it picks for the moment) for no apparent reason whatsoever.

I should note that the keys that the HKCR\.whr and HCKR\.encxml keys reference (Account Manager Encrypted XML File and Work Hours Record) have spaces in them, and when I created the association in Visual Studio, I did NOT add a "." to the front. Perhaps spaces are not allowed, and/or you're supposed to prefix with "."? The registry code seems OK, but I noticed by looking through my registry that every other application does NOT use a space in the association class, nor does this issue happen with ANY other file extension from any application installed on any machines I know of - only the ones created by my applications' VS installers. I've pasted a registry dump of the corresponding registry keys and values related to the file extensions - since MSI is proprietary I have no idea if this is all of it, but from what I know from other applications this should be everything. I've always wondered about this issue for years, but could never figure it out. I am replacing one of those old applications with a newer product soon, so this time I want to make sure there are no odd bugs like this...

Here's the data (note that I've indicated the text values of some binary strings with a // comment below the value):

[HKEY_CLASSES_ROOT\.encxml]
"Content Type"="application/octet-stream"
@="Account Manager Encrypted XML File"

[HKEY_CLASSES_ROOT\.encxml\Account Manager Encrypted XML File]

[HKEY_CLASSES_ROOT\.encxml\Account Manager Encrypted XML File\ShellNew]

[HKEY_CLASSES_ROOT\Account Manager Encrypted XML File]
@="Account Manager Encrypted XML File"

[HKEY_CLASSES_ROOT\Account Manager Encrypted XML File\DefaultIcon]
@=hex(2):25,00,41,00,50,00,50,00,44,00,41,00,54,00,41,00,25,00,5c,00,4d,00,69,\
  00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,5c,00,49,00,6e,00,73,00,74,00,\
  61,00,6c,00,6c,00,65,00,72,00,5c,00,7b,00,42,00,36,00,34,00,31,00,37,00,36,\
  00,30,00,42,00,2d,00,37,00,44,00,42,00,37,00,2d,00,34,00,46,00,31,00,42,00,\
  2d,00,41,00,44,00,36,00,45,00,2d,00,30,00,41,00,33,00,34,00,32,00,30,00,46,\
  00,35,00,45,00,45,00,30,00,44,00,7d,00,5c,00,5f,00,36,00,46,00,45,00,46,00,\
  46,00,39,00,42,00,36,00,38,00,32,00,31,00,38,00,34,00,31,00,37,00,46,00,39,\
  00,38,00,46,00,35,00,34,00,39,00,2e,00,65,00,78,00,65,00,2c,00,30,00,00,00

// Product code GUID is: {F7F214E9-ED37-4AE1-B0D2-93427973E60A}, which is different from below but I probably changed it at some point for some reason
// %APPDATA%\Microsoft\Installer\{B641760B-7DB7-4F1B-AD6E-0A3420F5EE0D}\_6FEFF9B68218417F98F549.exe,0

[HKEY_CLASSES_ROOT\Account Manager Encrypted XML File\shell]
@="open"

[HKEY_CLASSES_ROOT\Account Manager Encrypted XML File\shell\open]
@="&Open"

[HKEY_CLASSES_ROOT\Account Manager Encrypted XML File\shell\open\command]
@="\"C:\\Program Files\\Petroules Enterprises\\Account Manager\\AccountManager.exe\" \"%1\""
"command"=hex(7):4c,00,29,00,25,00,59,00,63,00,73,00,67,00,2d,00,4c,00,41,00,\
  28,00,30,00,64,00,66,00,34,00,36,00,75,00,5f,00,50,00,27,00,3e,00,27,00,7d,\
  00,27,00,66,00,25,00,6f,00,59,00,64,00,4b,00,69,00,48,00,74,00,7a,00,35,00,\
  21,00,55,00,2b,00,6c,00,68,00,54,00,20,00,22,00,25,00,31,00,22,00,00,00,00,\
  00

// This is a bizarre-looking value... what's up with that?
// L)%Ycsg-LA(0df46u_P'>'}'f%oYdKiHtz5!U+lhT "%1"

[HKEY_CLASSES_ROOT\.whr]
"Content Type"="application/octet-stream"
@="Work Hours Record"

[HKEY_CLASSES_ROOT\.whr\Work Hours Record]

[HKEY_CLASSES_ROOT\.whr\Work Hours Record\ShellNew]

[HKEY_CLASSES_ROOT\Work Hours Record]
@="Work Hours Record"

[HKEY_CLASSES_ROOT\Work Hours Record\DefaultIcon]
@=hex(2):25,00,41,00,50,00,50,00,44,00,41,00,54,00,41,00,25,00,5c,00,4d,00,69,\
  00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,5c,00,49,00,6e,00,73,00,74,00,\
  61,00,6c,00,6c,00,65,00,72,00,5c,00,7b,00,46,00,41,00,32,00,33,00,44,00,37,\
  00,36,00,34,00,2d,00,46,00,36,00,34,00,39,00,2d,00,34,00,38,00,46,00,39,00,\
  2d,00,38,00,44,00,30,00,42,00,2d,00,45,00,31,00,38,00,38,00,35,00,41,00,39,\
  00,38,00,31,00,46,00,39,00,39,00,7d,00,5c,00,5f,00,36,00,46,00,45,00,46,00,\
  46,00,39,00,42,00,36,00,38,00,32,00,31,00,38,00,34,00,31,00,37,00,46,00,39,\
  00,38,00,46,00,35,00,34,00,39,00,2e,00,65,00,78,00,65,00,2c,00,30,00,00,00

// Product code GUID: {FA23D764-F649-48F9-8D0B-E1885A981F99}, same as below
// %APPDATA%\Microsoft\Installer\{FA23D764-F649-48F9-8D0B-E1885A981F99}\_6FEFF9B68218417F98F549.exe,0

[HKEY_CLASSES_ROOT\Work Hours Record\shell]

[HKEY_CLASSES_ROOT\Work Hours Record\shell\open]
@="&Open"

[HKEY_CLASSES_ROOT\Work Hours Record\shell\open\command]
@="\"C:\\Program Files\\Petroules Enterprises\\Work Hours Calculator\\WorkHoursCalculator.exe\" \"%1\""
"command"=hex(7):28,00,5d,00,56,00,49,00,79,00,55,00,7b,00,5e,00,4e,00,3f,00,\
  26,00,68,00,48,00,7e,00,53,00,24,00,6e,00,31,00,36,00,59,00,3e,00,33,00,75,\
  00,5f,00,7d,00,47,00,26,00,70,00,79,00,75,00,78,00,38,00,4e,00,72,00,43,00,\
  6e,00,67,00,27,00,44,00,67,00,42,00,20,00,22,00,25,00,31,00,22,00,00,00,00,\
  00

// Same bizarre-looking type of value as before, but different...
// (]VIyU{^N?&hH~S$n16Y>3u_}G&pyux8NrCng'DgB "%1"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寄意 2024-09-18 20:36:03

在 Windows Installer 中,我们使用 RegisterExtensionInfo 标准操作:

http ://msdn.microsoft.com/en-us/library/aa371156(v=VS.85).aspx

主要使用扩展和动词表以及一些与 COM 相关表的联接:

http://msdn.microsoft.com/en-us/ Library/aa368571(v=VS.85).aspx(扩展表)
http://msdn.microsoft.com/en -us/library/aa372487(v=VS.85).aspx(动词表)

In Windows Installer we use the RegisterExtensionInfo standard action:

http://msdn.microsoft.com/en-us/library/aa371156(v=VS.85).aspx

Which uses principally uses the Extension and Verb tables along with some joins to COM related tables:

http://msdn.microsoft.com/en-us/library/aa368571(v=VS.85).aspx ( Extension Table )
http://msdn.microsoft.com/en-us/library/aa372487(v=VS.85).aspx ( Verb Table )

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文