Ok, so I decided to make a tutorial for visual basic classic programmers (aka vb6) who make a plugin for Messenger Plus! This tutorial will deal with making
an install script using INNO setup 5. Inno setup is freeware and can be downloaded here:
http://www.jrsoftware.org/isinfo.php (at the moment of writing this tutorial there seems to be a problem with the site)
As example for this tutorial i use the nicname counter plugin, i hope the author doesn't mind.
Once your plugin is finished, open Inno setup and create a new project using the Script Wizard. Make sure the create a new empty script box is unchecked and click next.
Fill in the details about your program as needed. Make sure you use the right version. If you are not a publisher leave the last two fields blank or use your name. Click next.
In the following window, click the other checkbox, the application doesn't need a directory and click next.
Add all the files your project needs (one of them ofcourse your plugin dll
), there can be some ocx files which are needed, not everybody has the visual
basic ide installed, keep this in mind. Click next
Provide the wizard with the pad to your licence file, keep in mind that for legal reasons this is certainly recommended (especially the liability part). click next
Finish the wizard, click no, the script shouldn't be compiled yet. Save the script.
In the files section remove the ignoreversion flag and replace it with a regserver flag for your plugin dll and every ocx or activeX dll your project
installs, a tlb file should be installed with a regtypelib flag
example pluginfile: Source: "C:\Documents and Settings\Administrator\Bureaublad\Count_Nickname\CountNick.dll"; DestDir: "{win}"; Flags: regserver
example ocx: Source: "c:\WINNT\system32\TABCTL32.OCX"; DestDir: "{sys}"; Flags: sharedfile regserver
notice the destination directory system and the sharedfile flag used for activex components, this is important!
also notice the destination directory of your plugin is defaulted to win, this is because you chose not to make an application directory, we will change
this. Replace DestDir: "{win}" with DestDir: "{reg:HKLM\SOFTWARE\Patchou\MsgPlus2,PluginDir|NotFound}", this should install the plugin to the default plugin
directory of Messenger Plus!
next make a code section in your script after your file section by putting [ Code ] without the spaces.
make a constant section with two vars:
code:
const
ValueName = 'Nickname Counter';
ValueClass = 'CountNick.clsCountNick';
Valuename can be whatever you like, keep it meaningful, valueclass should be the name of your class.
next add the following function to your code section
code:
function MsgPlusCheck(): Boolean;
var
MyProgCheckResult : Boolean;
begin
if RegValueExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Patchou\MsgPlus2', 'PluginDir') then begin
MyProgCheckResult := True;
end else
MyProgCheckResult := False;
if MyProgCheckResult = False then begin
MsgBox('The installation wizard detected that you don''t have Messenger Plus! installed. The installation will be aborted.', mbInformation, MB_OK);
end;
Result := MyProgCheckResult;
end;
This function will check if the user has msgplus installed and will abort if not. Note: this function is not bulletproof, check if the msgplus file exists or
if the process is running if you want te be 100% sure.
This function should be called before the file is installed en should abort the installation of the file if msgplus is not installed, therefore add the
following part to your files section (the plugin file line)
Check: MsgPlusCheck();
This line should now look like this:
Source: "C:\Documents and Settings\Administrator\Bureaublad\Count_Nickname\CountNick.dll"; Check: MsgPlusCheck(); DestDir:
"{reg:HKLM\SOFTWARE\Patchou\MsgPlus2,PluginDir|NotFound}"; Flags: regserver
Add following procedure to your code section
code:
procedure InstallPlugin;
var
nMsg : LongInt;
begin
if RegWriteStringValue(HKLM, 'SOFTWARE\Patchou\MsgPlus2\RegisteredPlugins', ValueName, ValueClass) then begin
nMsg := RegisterWindowMessage('MessengerPlus_PluginChange');
PostBroadcastMessage(nMsg, 0, 0);
end else
MsgBox('The Messenger Plus! plugin couldn''t be installed due to an unknown error', MbInformation, MB_OK);
end;
This will cause Messenger Plus to reload it's plugins
To call this function add BeforeInstall: InstallPlugin; to your files section, you become this
Source: "C:\Documents and Settings\Administrator\Bureaublad\Count_Nickname\CountNick.dll"; Check: MsgPlusCheck(); BeforeInstall: InstallPlugin; DestDir:
"{reg:HKLM\SOFTWARE\Patchou\MsgPlus2,PluginDir|NotFound}"; Flags: regserver
Now you're almost done, the only thing left is the uninstallation of the plugin
Add this function to your code section
code:
function InitializeUninstall(): Boolean;
var
nMsg : LongInt;
begin
if MsgPlusCheck() then begin
MsgBox('It is recommended that you close MSN Messenger before continuing.', MbInformation, MB_OK);
end;
Result := True;
RegDeleteValue(HKLM, 'SOFTWARE\Patchou\MsgPlus2\RegisteredPlugins', ValueName);
nMsg := RegisterWindowMessage('MessengerPlus_PluginChange');
PostBroadcastMessage(nMsg, 0, 0);
end;
That's it, no more restarting messenger, no more bat files. I hope this helped some of you. Included is the complete source and it's compiled version. have
fun.
XerXis
co-founder of SodeX bvba (srr, always wanted to say that
)