|
楼主 |
发表于 2019-3-15 21:56
|
显示全部楼层
[ComRegisterFunction]
public static void RegisterFunciton(Type type)
{
Registry.ClassesRoot.CreateSubKey(GetSubKeyName(type,"Programmable"));
var key = Registry.ClassesRoot.OpenSubKey(GetSubKeyName(type, "InprocServer32"));
key.SetValue("", Environment.SystemDirectory + @"\mscoree.dll", RegistryValueKind.String);
}
[ComUnregisterFunction]
public static void UnregisterFunction(Type type)
{
Registry.ClassesRoot.DeleteSubKey(GetSubKeyName(type, "Programmable"),false);
}
private static string GetSubKeyName(Type type,string subKeyName)
{
var s = new System.Text.StringBuilder();
s.Append(@"CLSID\{");
s.Append(type.GUID.ToString().ToUpper());
s.Append(@"}\");
s.Append(subKeyName);
return s.ToString();
}
从EXCEL中可以看到这个类是写在C:\Windows\SysWOW64\mscoree.dll里面的,打开注册表搜索可以查到mscoree.dll,Registry.ClassesRoot 对应于HKEY_CLASSES_ROOT主键,在注册表里注册了这个函数,没办法删除的,死心吧 |
|