private static void SaveReg(string _FilePathString
, string p_FileTypeName
)
{
RegistryKey _RegKey
= Registry
.ClassesRoot
.OpenSubKey("", true);
RegistryKey _VRPkey
= _RegKey
.OpenSubKey(p_FileTypeName
, true);
if (_VRPkey
!= null)
{
_RegKey
.DeleteSubKey(p_FileTypeName
, true);
}
_RegKey
.CreateSubKey(p_FileTypeName
);
_VRPkey
= _RegKey
.OpenSubKey(p_FileTypeName
, true);
_VRPkey
.SetValue("", "Exec");
_VRPkey
= _RegKey
.OpenSubKey("Exec", true);
if (_VRPkey
!= null)
{
_RegKey
.DeleteSubKeyTree("Exec");
}
_RegKey
.CreateSubKey("Exec");
_VRPkey
= _RegKey
.OpenSubKey("Exec", true);
_VRPkey
.CreateSubKey("shell");
_VRPkey
= _VRPkey
.OpenSubKey("shell", true);
_VRPkey
.CreateSubKey("open");
_VRPkey
= _VRPkey
.OpenSubKey("open", true);
_VRPkey
.CreateSubKey("command");
_VRPkey
= _VRPkey
.OpenSubKey("command", true);
string _PathString
= "\"" + _FilePathString
+ "\" \"%1\"";
_VRPkey
.SetValue("", _PathString
);
_RegKey
.CreateSubKey("DefaultIcon");
_RegKey
.SetValue("", Application
.StartupPath
+ "\\"+ "LedsMaker.ico");
_VRPkey
= _VRPkey
.OpenSubKey("DefaultIcon", true);
}
public static void FileAssociationInit()
{
string str
;
str
= Application
.ExecutablePath
;
SaveReg(str
, ".usrExt");
}
转载请注明原文地址:https://tech.qufami.com/read-4250.html