Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Register a BHO through an NSIS installer (http://forums.winamp.com/showthread.php?t=320125)

kumar.kapil 21st June 2010 16:02

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

Afrow UK 22nd June 2010 15:26

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

th_mi 23rd June 2010 08:37

Quote:

Originally Posted by kumar.kapil (Post 2673746)
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

Afrow UK 23rd June 2010 09:06

Do you have to use regsvr32? What about NSIS's RegDLL?

Stu

th_mi 24th June 2010 08:38

Quote:

Originally Posted by Afrow UK (Post 2674234)
Do you have to use regsvr32?

No, if you know RegDLL :)

Quote:

Originally Posted by Afrow UK (Post 2674234)
What about NSIS's RegDLL?

Now I can use it, since I know it ;)


All times are GMT. The time now is 17:33.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.