2011-05-31 81 views

回答

1

您必须更改注册表项:HKEY_CLASSES_ROOT\txtfile\shell\open\command。看看regedit.exe。您也可以看看这个键:HKEY_CLASSES_ROOT\.txt

要操纵一个注册表项,使用System.Win32.Registry这里的Docs

1

下面是关于如何做到这一点的一种方法(以VB)。 ApplicationTag是注册表的简称,如editor3.1。您可以使用注册表检查注册表以查看发生了什么,并且在测试应用程序的这部分之前,您可能需要创建一个还原点。

Imports Microsoft.Win32 

...

Registry.SetValue("HKEY_CURRENT_USER\software\classes\" & FileType, "", applicationTag) 
q = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & FileType, True) 
If q IsNot Nothing AndAlso q.GetValue("ProgID", "notfound") <> "notfound" Then 
    q.SetValue("ProgID", appTag) ' for the local user, overrides hkcr 
    End If 
appKey = "HKEY_CURRENT_USER\software\classes\" & applicationTag 
Registry.SetValue(appKey, "", "text") 
Registry.SetValue(appKey & "\shell", "", "open") 
Registry.SetValue(appKey & "\shell\open", "", "") 

Registry.SetValue(appKey & "\shell\open\command", "", """" & ApplicationPath & """ ""%1""") 
Registry.SetValue(appKey, "", "text") 
appKey = "HKEY_CURRENT_USER\software\classes\CLSID\" & ApplicationGuid 
Registry.SetValue(appKey, "", applicationTitle) 
Registry.SetValue(appKey & "\ProgID", "", applicationTag) 
相关问题