Old 21st June 2010, 17:02   #1
kumar.kapil
Junior Member
 
Join Date: Jun 2010
Posts: 1
Register a BHO through an NSIS installer

I have an IE BHO which I was packaging through the Visual Studio setup and deployment project. I now want to the package it through an NSIS installer.

My BHO was registering in the following way:

[ComRegisterFunctionAttribute]
public static void Register(Type t)
{
string guid = t.GUID.ToString("B");

RegistryKey rkClass = Registry.ClassesRoot.CreateSubKey(@"CLSID\"+guid );
RegistryKey rkCat = rkClass.CreateSubKey("Implemented Categories");

string name = toolbarName;
string help = toolbarHelpText;

rkClass.SetValue(null, name );
rkClass.SetValue("MenuText", name );
rkClass.SetValue("HelpText", help );

if( 0 != (style & BandObjectStyle.Vertical) )
rkCat.CreateSubKey("{00021493-0000-0000-C000-000000000046}");

if( 0 != (style & BandObjectStyle.Horizontal) )
rkCat.CreateSubKey("{00021494-0000-0000-C000-000000000046}");

if( 0 != (style & BandObjectStyle.TaskbarToolBar) )
rkCat.CreateSubKey("{00021492-0000-0000-C000-000000000046}");

if( 0 != (style & BandObjectStyle.ExplorerToolbar) )
Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Toolbar").SetValue(guid,name);

}

While this is taken care of by the msi installer that is made by VS, I want to know how can I do the same using NSIS?

Any help would be appreciated!

Kapil
kumar.kapil is offline   Reply With Quote
Old 22nd June 2010, 16:26   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
If it's just a matter of writing those registry values then you've got all the registry functions in the NSIS documentation. You'll just have to get the GUID and pass it to NSIS. You could do this via a .NET DLL (invoked using the CLR plug-in) or via a .NET console app which you execute with ExecDos/nsExec.

Stu
Afrow UK is offline   Reply With Quote
Old 23rd June 2010, 09:37   #3
th_mi
Member
 
Join Date: Sep 2005
Location: Sitting next to my desk
Posts: 56
Quote:
Originally Posted by kumar.kapil View Post
RegistryKey rkClass = Registry.ClassesRoot.CreateSubKey(@"CLSID\"+guid );
RegistryKey rkCat = rkClass.CreateSubKey("Implemented Categories");

string name = toolbarName;
string help = toolbarHelpText;

rkClass.SetValue(null, name );
rkClass.SetValue("MenuText", name );
rkClass.SetValue("HelpText", help );

if( 0 != (style & BandObjectStyle.Vertical) )
rkCat.CreateSubKey("{00021493-0000-0000-C000-000000000046}");

if( 0 != (style & BandObjectStyle.Horizontal) )
rkCat.CreateSubKey("{00021494-0000-0000-C000-000000000046}");

if( 0 != (style & BandObjectStyle.TaskbarToolBar) )
rkCat.CreateSubKey("{00021492-0000-0000-C000-000000000046}");

if( 0 != (style & BandObjectStyle.ExplorerToolbar) )
Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Toolbar").SetValue(guid,name);
Your GUID should be known, than you can do it all by yourself using the Registry functions WriteRegXXX of NSIS.

If your shell extension DLL (hopefully) meets the Microsoft design guidlines there is also an much more easier way:

You can use the exported function DllRegisterServer (and for uninstalling DllUnregisterServer). This can easyly done using "RegSvr32.exe". This would be in NSIS like this command:

Install:
code:
ExecWait "$SYSDIR\regsvr32.exe /s $\"$INSTDIR\YourDLLName.dll$\""

Uninstall:
code:
ExecWait "$SYSDIR\regsvr32.exe /s /u $\"$INSTDIR\YourDLLName.dll$\""


It is important tu use quotation marks in the command argument of RegSvr32 since the setup directory may contain spaces. If the quotation marks are missing the command argument will be cut at the first space in the argument by RegSvr32!

In case your shell extension DLL does not support the registering and unregistering process completely I advice you to implement this in you DLL. This may be needed in case a re-registering or a manual unregistering is nesessary. This makes life much much easier for your customer support!

hope this helped a little!?

Best regards

th_mi

This signature is currently on vacation!
th_mi is offline   Reply With Quote
Old 23rd June 2010, 10:06   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Do you have to use regsvr32? What about NSIS's RegDLL?

Stu
Afrow UK is offline   Reply With Quote
Old 24th June 2010, 09:38   #5
th_mi
Member
 
Join Date: Sep 2005
Location: Sitting next to my desk
Posts: 56
Quote:
Originally Posted by Afrow UK View Post
Do you have to use regsvr32?
No, if you know RegDLL

Quote:
Originally Posted by Afrow UK View Post
What about NSIS's RegDLL?
Now I can use it, since I know it

This signature is currently on vacation!
th_mi is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
ie bho com register dll

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump