Writing Your Own Installer?

Started by
16 comments, last by RomSteady 18 years, 11 months ago
As you all may realise by now, i like writing alot of code myself, then use the real stuff once i know the basis on which they work. So now i want to write my own text based installer. Just a couple of things i want to clarify. What does say Install Shield actually do? Does it simple put a shortcut in the appropriate start menu folder and the desktop for the menu items and icons? How does it put stuff in the registry (if it does actually do this) and make it so the uninstaller appears in the Add Remove Programs list. In general how does this all work. ace
Advertisement
Have a look at the Nullsoft Installation System. It's OSS and you can get all the information you need from their source code.


[Edited by - darookie on May 2, 2005 9:33:16 AM]
InstallShield does a lot of stuff for you. The most basic thing, of course, is extracting and copying files to the destination folder. For DLLs shared by multiple applications, there are counters somewhere which keep track of how many installing applications are requiring them.

For COM DLLs, it can execute DllRegisterServer() like RegSvr32.exe does, or directly dump the GUIDs into the registry, I think by monitoring which changed DllRegisterServer() does at the time you create your setup. Registry modifications, I suppose, are being done using the normal RegOpenKey()/RegCreateKey() API functions.

If a file to be replaced is non-writable, it somehow queues the file update for the next reboot, probably through a special service launcher which executes before any windows apps get the chance to.

There's also a special kind of link which can't be modified that InstallShield creates and there must be more than one way to put entries in the start menu. If you just copy links into the start menu folder, windows will not highlight the newly added entries.

-Markus-
Professional C++ and .NET developer trying to break into indie game development.
Follow my progress: http://blog.nuclex-games.com/ or Twitter - Topics: Ogre3D, Blender, game architecture tips & code snippets.
Well slap my thy and call it Henry there is alot an installer does.

ace
First of all you will need to make a folder in this location:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

afaik you can't use spaces, but I could be mistaken.

Inside this folder is where you store all uninstall information. The 2 items required by windows are:

DisplayName (String)
This is what you will see in "Add/Remove Programs"

UninstallString (String)
The command that will execute the uninstaller.

You can also put custom data into the folder - just make sure the names don't clash with the 2 above.


Here is the complete entry from the game EVE-Online:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\EVE]
"DisplayName"="EVE-ONLINE (remove only)"
"UninstallString"="C:\\Program Files\\CCP\\EVE\\Uninstall.exe"

Don't forget to delete the folder (in this case "EVE") once you've uninstalled!
Ok, so lets clarify,

1) Obviously will have gathered all game resources etc, assuming a full game CD is complete having been published etc.


2) In what order would the following be done.

- Create registry folder as described above.
- Create a shortcut and add it to the menus, looks easy apart from how to actually make the shortcut.
- Copy all the stuff accross.


What else is there? And have you any ideas how i create the shortcut? I found some IShell interface stuff but it doesnt have any examples.

ace
I really would recommend NSIS. It'll let you explore the questions you're asking and you can see what it does and how.
Quote:Well slap my thy and call it Henry there is alot an installer does.

It's 'thigh'. Took me ages to remember how to spell it. After seeing you spell it 'thy', I had a total mental block. Had to type in "connected to the knee bone" in google. [smile]
As for other things installers do, a good installer:

1) Will not allow you to install to an invalid folder (too many characters, bad path, special device [no installing to PRN: for you...])

2) Will detect if you are running as a limited user, and if so, will not allow you to install

3) Recognizes silent (administrative) install options

4) Verifies each file on install

5) Properly rolls back the system to its original state should the install be cancelled or unable to continue due to files missing from the installer or a file not copying over correctly (see #4)

6) Detects missing prerequisites (MDAC, DirectX, service packs) and either launches their installers or stops and requires the user to install

7) During install, asks if the program should be installed for all users or just the current user and directs the shortcuts properly (either installer's users Start Menu folder, or Docs&Settings "All Users" Start Menu folder.)

8) Allows wildcard creation of registry keys based on installation path

Just a few things to keep in mind...
Michael Russell / QA Manager, Ritual EntertainmentI used to play SimCity on a 1:1 scale.
If your installer isn't transactional, it is worthless. Nothing worse than having an installation fail and it doesn't clean up after itself. Similarly, the uninstall function should completely uninstall every trace of the program from the system.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
Quote:Original post by petewood
I really would recommend NSIS. It'll let you explore the questions you're asking and you can see what it does and how.
Quote:Well slap my thy and call it Henry there is alot an installer does.

It's 'thigh'. Took me ages to remember how to spell it. After seeing you spell it 'thy', I had a total mental block. Had to type in "connected to the knee bone" in google. [smile]


well it should be thy dammit!!

:)

ACE

This topic is closed to new replies.

Advertisement