Shoutbox

Tutorial: making an installer for your plugin in a few easy steps - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: Tutorial: making an installer for your plugin in a few easy steps (/showthread.php?tid=42157)

Tutorial: making an installer for your plugin in a few easy steps by Xerxis on 04-07-2005 at 08:26 PM

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 :p)
RE: install script by Jhrono on 04-07-2005 at 09:01 PM

i really don't get what you mean sorry..:S...Do you want somebody to make you a setup file for your plugin?


RE: install script by Mike on 04-07-2005 at 09:47 PM

quote:
Originally posted by johny
i really don't get what you mean sorry..:S...Do you want somebody to make you a setup file for your plugin?
He made a setup script for Inno Setup and he is sharing the source of the installer he made with us :)

Anyway, I didn't know that you could use api calls in inno setup...
RE: install script by Xerxis on 04-08-2005 at 06:51 AM

Sorry if it wasn't very clear, maybe i'll make an example of how to make an inno setup project for Plus! Plugins, as i noticed a lot of developers use a bat file and require the user to restart messenger. And since inno setup 4 you can do a lot with it, i like the delphi scripting engine that is included :) (makes me think those years of turbo pascal in high school weren't a waste of time after all :p)


RE: Tutorial: making an installer for your plugin in a few easy steps by (CyBeRDuDe) on 04-08-2005 at 11:36 AM

That is really nice done Xerxis!!! Nice information!!! :D I would use this.. And I don't mind you using my counter plugin as example!!! :D
Could you do one thing more?...
Maybe make a function that checks if the file/plugin already exists... If it does then Messenger Should be closed/exited/task killed before installing the plugin, since I can not overwrite the plugin if messenger is running, and using the reloadplugins api doesn't work when the plugins are made in VB6... :(... If you add a function/support for this then this turtorial would be perfect!!! :D.. Nice done mate!!!


RE: Tutorial: making an installer for your plugin in a few easy steps by Xerxis on 04-08-2005 at 12:35 PM

I can install a plugin several times without deleting the file? Reloadplugins works fine I thought, I tested it with you plugin and it showed up in the plugin menu without problems :). If it doesn't work with you i'll make a function that terminates the Messenger Plus! process


RE: Tutorial: making an installer for your plugin in a few easy steps by (CyBeRDuDe) on 04-08-2005 at 02:39 PM

It works?... Also with my plugin???... Whenever I try using the same reload api code you use, and try to overwrite the existing plugin dll file it won't let me... since it's in use.. and in matter of fact it was a known fact that the reload funtion doesn't unload vb6 dll files... :S..  Unless this have been fixed in 3.50 I don't know?.... I'll just check out the installer soon.. :D...


RE: Tutorial: making an installer for your plugin in a few easy steps by Xerxis on 04-08-2005 at 03:14 PM

works on my win2k machine without problems :)


RE: Tutorial: making an installer for your plugin in a few easy steps by eSouL on 10-27-2005 at 05:07 PM

Hi Xerxis,

Thanks for the great tutorial! I have a question though..

How do I specify the subdirectory to install at? For instance, I have a plugin called ABC.dll, and in the plugin folder i have a subfolder 'ABC', which contains another two subfolders 'graphics' and 'lib', lib being the place I keep all the dll and activex ocx.

How do I go about making the installer create the folder structure correctly and install those files in their respecive folders?

EDIT: Never mind I figured out how (Y)


RE: Tutorial: making an installer for your plugin in a few easy steps by Tobiaz on 10-29-2005 at 01:31 PM

Fuckin' great Tutorial!

Thank you very, very much! It's exactly that, I was searching for!

(h5)(h5)(h5)(h5)(h5)(h5)(h5)(h5)(h5)(h5)

Greeeeeeez


RE: Tutorial: making an installer for your plugin in a few easy steps by parveenjain on 08-13-2008 at 11:52 AM

Hi Xerix,
Thanks for this tutorial.

I have one small question , how we can determine that installation was failed, aborted , sucessfull  or anything else happened to it.

I mean which event will trigeer in this case.


Hi Xerxis,
  In my inno setup program I wanted to know the "exit error codes" so that I can determine what happened to my installation.
is there any way to do it in ecript itself ?

Though I had found some exit codes , but don't know which inno function(or const) can give me these error codes? Are these error codes only available If I am using shellExecute().

Please see if it you can help as I  require it very urgently and I am in my last phase of it.

Regards,
Parveen

PS. Please let me know If you wanted to know somehting more about my problem.


RE: Tutorial: making an installer for your plugin in a few easy steps by CookieRevised on 08-16-2008 at 11:33 AM

You might wanna read the help files for INNO setup. If there is a buildin function which can return it, it will be listed in the help files/pages.

------

The ShellExecute() and ShellExecuteEx() Windows APIs do not return a process' exit code! Neither ShellExecute(), nor ShellExecuteEx() can help you with this. Those APIs can't be used for this.

If you want to use a Windows API to do that you need to use the Windows API GetProcessExitCode().

For this you need to get a process handle which can be used as a parameter for GetProcessExitCode(). To get this process handle you must use the Windows API OpenProcess or CreateProcess or the likes.

For more detailed help and how exactly all those APIs are used, see the MSDN Library