Developing a Browser Toolbar: Installation System (4/5)

This post series reflects my article “Developing a Browser Toolbar” published in the ASPects in January 2010 (Volume 23, Issue 1), a magazine of the Association of Shareware Professionals (ASP).

Now we have a toolbar for Internet Explorer and Firefox, but how do we get them installed? There is only one installation tool I’m using also for all my other products that can do almost everything: Inno Setup. Here is what you need for the installation of both toolbar versions.

Mozilla Firefox Toolbar Installation

Again it is much easier to install a new toolbar for the Firefox browser. You only need to copy your XPI file to the Firefox extension directory. The toolbar will then be installed at the next browser start. So we need only one additional Pascal function in our Inno Setup code to figure out the extension directory of Firefox:

function GetFirefoxExtensionsPath(Param: String): String;
var
    FirefoxVersion, FirefoxInstallPath: string;
begin
    if (RegQueryStringValue(HKLM, 'SOFTWARE\Mozilla\Mozilla Firefox',
            'CurrentVersion', FirefoxVersion)) then begin
        if (RegQueryStringValue(HKLM, 'SOFTWARE\Mozilla\Mozilla Firefox\' + FirefoxVersion +
                '\Main', 'Install Directory', FirefoxInstallPath)) then begin
            if (not DirExists(FirefoxInstallPath +
                   '\extensions\toolbarebay@ab-tools.com')) then begin
                Result := FirefoxInstallPath + '\extensions';
            end;
        end;
    end;
end;

Microsoft Internet Explorer Toolbar Installation

To install the toolbar for the Internet Explorer we first have to register the strongly-named assembly in the Global Assembly Cache (GAC) by using the gacinstall flag of the file section provided in the current Inno Setup version. Additionally we need to make quite a few registry changes. You can copy the following code into the registry section of your Inno Setup script and replace all variables by your own values (I’ve shortened the Inno Setup syntax a little bit to get it more compact):

HKCR: CLSID\{{%GUID%}; Flags: uninsdeletekey
HKCR: CLSID\{{%GUID%}; ValueType: string; ValueName: ; ValueData: %LONG_NAME%
HKCR: CLSID\{{%GUID%}; ValueType: string; ValueName: MenuText; ValueData: %LONG_NAME%
HKCR: CLSID\{{%GUID%}; ValueType: string; ValueName: HelpText; ValueData: %DESCRIPTION%
HKCR: CLSID\{{%GUID%}\Implemented Categories\{{00021494-0000-0000-C000-000000000046}
HKCR: CLSID\{{%GUID%}\InprocServer32; ValueType: string; ValueName: ; ValueData: mscoree.dll
HKCR: CLSID\{{%GUID%}\InprocServer32; ValueType: string; ValueName: ThreadingModel; ValueData: Both
HKCR: CLSID\{{%GUID%}\InprocServer32; ValueType: string; ValueName: Class; ValueData: %CLASS%
HKCR: CLSID\{{%GUID%}\InprocServer32; ValueType: string; ValueName: Assembly; ValueData: %NAMESPACE%, Version=%VERSION%, Culture=neutral, PublicKeyToken=%PUBLIC_KEY%
HKCR: CLSID\{{%GUID%}\InprocServer32; ValueType: string; ValueName: RuntimeVersion; ValueData: v2.0.50727
HKLM: Software\Classes\CLSID\{{%GUID%}; Flags: uninsdeletekey
HKLM: Software\Classes\CLSID\{{%GUID%}; ValueType: string; ValueName: ; ValueData: %LONG_NAME%
HKLM: Software\Classes\CLSID\{{%GUID%}; ValueType: string; ValueName: MenuText; ValueData: %LONG_NAME%
HKLM: Software\Classes\CLSID\{{%GUID%}; ValueType: string; ValueName: HelpText; ValueData: %DESCRIPTION%
HKLM: Software\Classes\CLSID\{{%GUID%}\Implemented Categories\{{00021494-0000-0000-C000-000000000046}
HKLM: Software\Classes\CLSID\{{%GUID%}\InprocServer32; ValueType: string; ValueName: ; ValueData: mscoree.dll
HKLM: Software\Classes\CLSID\{{%GUID%}\InprocServer32; ValueType: string; ValueName: ThreadingModel; ValueData: Both
HKLM: Software\Classes\CLSID\{{%GUID%}\InprocServer32; ValueType: string; ValueName: Class; ValueData: %CLASS%
HKLM: Software\Classes\CLSID\{{%GUID%}\InprocServer32; ValueType: string; ValueName: Assembly; ValueData: %NAMESPACE%, Version=%VERSION%, Culture=neutral, PublicKeyToken=%PUBLIC_KEY%
HKLM: Software\Classes\CLSID\{{%GUID%}\InprocServer32; ValueType: string; ValueName: RuntimeVersion; ValueData: v2.0.50727
HKLM: SOFTWARE\Microsoft\Internet Explorer\Toolbar; ValueType: string; ValueName: {{%GUID%}; ValueData: %LONG_NAME%
HKLM: SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\{{%GUID%}; Flags: uninsdeletekey
HKLM: SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\{{%GUID%}; ValueType: dword; ValueName: NoExplorer; ValueData: 1

To not write useless trash to the user’s computer, the registry changes should only be performed and the files only be copied if the .NET Framework 2.0 (or higher) is installed on the system, because this is needed for the Internet Explorer toolbar as already written above. You can check the availability of the .NET Framework 2.0 quite easy with following Pascal function:

function CheckForDotNet(): Boolean;
begin
    Result := RegKeyExists(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727');
end;

These are the steps to create an Inno Setup installer for both toolbar versions. Of course, you can combine them in a single setup file that installs in Internet Explorer as well as the Firefox version depending on which browser is installed on the system.

The last post will be a short summary.

Contents of Post Series “Developing a Browser Toolbar”:

This post is also available in Deutsch.

One thought on “Developing a Browser Toolbar: Installation System (4/5)

  1. Pingback: Developing a Browser Toolbar: Microsoft Internet Explorer (3/5) | AB-WebLog.com

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>