从C#代码中重生BHO [英] Regasm BHO from C# Code
本文介绍了从C#代码中重生BHO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有带有BHO IE插件的DLL.
I have DLL With BHO IE Plugin.
然后我使用" regasm.exe/codebase myBHO.dll "注册我的dll.
And I use "regasm.exe /codebase myBHO.dll" to register my dll.
在Windows应用程序中是否有任何C#代码对我的DLL 重新填充?
Is there any C# code to regasm my DLL in windows application?
推荐答案
为此创建专用的安装程序.
Create a dedicated installer for this.
要从Visual Studio进行快速调试,请设置一些构建事件,如下所示:
For quick debugging cycles from Visual Studio, setup some Build Events like so:
"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]
,例如:
Then, define a [ComRegisterFunction]
like:
[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);
}
}
}
这篇关于从C#代码中重生BHO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文