我有BHO IE插件的DLL。
我使用" regasm.exe / codebase myBHO.dll "注册我的dll。
在Windows应用程序中,我的DLL是否有 regasm 的C#代码?
答案 0 :(得分:2)
为此创建专用安装程序。
对于Visual Studio的快速调试周期,请设置一些构建事件,如下所示:
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\x64\gacutil.exe" /f /i $(TargetDir)$(TargetFileName)
"%WINDIR%\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe" /unregister $(TargetDir)$(TargetFileName)
"%WINDIR%\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe" $(TargetDir)$(TargetFileName) /regfile:$(TargetFileName)64.reg
"%WINDIR%\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe" /codebase $(TargetDir)$(TargetFileName)
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\gacutil.exe" /f /i $(TargetDir)$(TargetFileName)
"%WINDIR%\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" /unregister $(TargetDir)$(TargetFileName)
"%WINDIR%\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" $(TargetDir)$(TargetFileName) /regfile:$(TargetFileName)32.reg
"%WINDIR%\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" /codebase $(TargetDir)$(TargetFileName)
然后,定义一个[ComRegisterFunction]
,如:
[ComRegisterFunction]
public static void RegisterBHO(Type type)
{
RegistryKey key;
using (key = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects"))
{
RegistryKey bhoKey;
using (bhoKey = key.CreateSubKey(typeName))
{
bhoKey.SetValue(string.Empty, "My Awesone IE Plugin");
bhoKey.SetValue("NoExplorer", 1, RegistryValueKind.DWord);
}
}
}