home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / ARQS_ZIP / INSPRO.ZIP / INSTLIB.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-04-28  |  15.0 KB  |  297 lines

  1. Library Install;
  2.  
  3. {$D INSTLIB.DLL - ⌐ Copyright 1992 Robert Salesas, All Rights Reserved.}
  4. {$I-}
  5. {$M 1024,1024
  6. {
  7. ********************************************************************
  8. *                  EDI Install Pro for Windows                     *
  9. *                      Demo custom library                         *
  10. ********************************************************************
  11. *       Copyright 1992 Robert Salesas, All Rights Reserved         *
  12. ********************************************************************
  13. *      Version: 1.00             Author:  Robert Salesas           *
  14. *      Date:    13-Apr-1992      Changes: Original                 *
  15. *                                                                  *
  16. ********************************************************************
  17. }
  18.  
  19.  
  20. Uses WinTypes, WinProcs;
  21.  
  22.  
  23.  
  24. Const { Procedure call codes }
  25.   icm_Setup       = 10;         { Called before first dialog box.                }
  26.   icm_Setup2      = 20;         { Called after first dialog box.                 }
  27.   icm_Components  = 30;         { Called before components dialog box.           }
  28.   icm_Components2 = 40;         { Called after components dialog box.            }
  29.   icm_StartCopy   = 50;         { Called before files start getting copied.      }
  30.   icm_FileCopy    = 60;         { Called for each file that needs to get copied. }
  31.   icm_EndCopy     = 70;         { Called all files have been copied.             }
  32.   icm_PMGroup     = 80;         { Called before the PM group dialog box.         }
  33.   icm_ExtraStuff  = 90;         { Called once the installation is completed.     }
  34.   icm_EndDlgGood  = 100;        { Called before the last dialog box.             }
  35.   icm_EndDlgBad   = 110;        { Called before the last dialog box.             }
  36.   icm_EndInstall  = 120;        { Called before program terminates.              }
  37.  
  38.  
  39. Const
  40.   ir_Continue     = 0;          { Continue with normal execution.              }
  41.   ir_SkipSection  = 1;          { Skip this section.                           }
  42.   ir_AbortInstall = -1;         { Abort the installation with proper messages. }
  43.  
  44.  
  45.  
  46. {
  47.   Declaration:
  48.   ~~~~~~~~~~~~
  49.  
  50.   Function InstallDLLProc(Instance : THandle;  Code : Integer;  Src, Dest : PChar;
  51.                           Var Components : LongInt) : Integer;  Export;
  52.  
  53.   Description:
  54.   ~~~~~~~~~~~~
  55.  
  56.   Allows custom modification of the installation.  You may use or change the values
  57.   passed to your function.  By creating routines to handle special parts of your
  58.   installation (such as extra setup information or copying specially encoded files),
  59.   you can completely customize EDI Install Pro without having to write your own
  60.   installer.  There's very little (if anything) that can't be handled through a
  61.   custom DLL.  Since the DLL can be written in almost any language, you don't have
  62.   to learn to program in some strange "installer" language.
  63.  
  64.   To add a DLL to an installation script simply add the following under the [APPLICATION]
  65.   section, if it's not compressed:
  66.  
  67.       [APPLICATION]
  68.       Install DLL=INSTLIB.DLL N
  69.  
  70.   and if it is:
  71.  
  72.       [APPLICATION]
  73.       Install DLL=INSTLIB.DL$ Y
  74.  
  75.  
  76.   Parameters:
  77.   ~~~~~~~~~~~
  78.  
  79.   Instance      The instance handle of the install application.  You can use it to access
  80.                 resources stored in the EXE.  If you need to create new resources, add them
  81.                 to the DLL, not INSTALL.EXE.
  82.  
  83.   Code          Specifies when the procedure is getting called.  Each code allows you to
  84.                 perform certain actions.  Note that you don't have to handle every code, only
  85.                 the ones you want.  Simply return ir_Continue for any code you don't want to
  86.                 handle.
  87.  
  88.  
  89.                 icm_Setup           Src and Dest contain the default values for the
  90.                                     directories. Components are all turned on.
  91.  
  92.                                     You may modify the default values of Src and Dest.
  93.                                     Override (return ir_SkipSection) this section if you want
  94.                                     to include your own "Get destination" dialog box.
  95.  
  96.  
  97.                 icm_Setup2          Dest contains the value entered by the user.  Src and
  98.                                     Components are unchanged.
  99.  
  100.                                     You may modify the value of Dest that the user entered.
  101.                                     If you require extra setup information from the user, this
  102.                                     is the place to get it.  Pop up whatever dialogs you need.
  103.                                     You can store the information in the DLL, since it will
  104.                                     always be accessed by only one instance.
  105.  
  106.  
  107.                 icm_Components      Src, Dest and Components are unchanged.
  108.  
  109.                                     Override this section if you want to include your own
  110.                                     "Select Components" dialog box, or if you want to "force"
  111.                                     component selection.  For example you might want to use a
  112.                                     simple dialog box with radio buttons instead of the listbox.
  113.  
  114.  
  115.                 icm_Components2     Components contains the value selected by the user.
  116.                                     Src and Dest are unchanged.
  117.  
  118.                                     You may modify the value of Components that the user
  119.                                     entered.  If you require extra component or setup
  120.                                     information from the user, this is the place to get it.
  121.                                     Pop up whatever dialogs you need.  You can store the
  122.                                     information in the DLL, since it will always be
  123.                                     accessed by only one instance.
  124.  
  125.  
  126.                 icm_StartCopy       Src, Dest and Components are unchanged.
  127.  
  128.                                     This call is made before any files get copied.  Use this
  129.                                     call for any setup procedure you need if you use
  130.                                     icm_FileCopy.  For example, if you wanted to display
  131.                                     small messages on a separate as files get copied, you
  132.                                     would open the window in this call.
  133.  
  134.  
  135.                 icm_FileCopy        Src and Dest contain the SOURCE FILE PATH and the
  136.                                     DESTINATION FILE PATH.  This differs from all the other
  137.                                     calls.  Note the file name of Src and Dest might not
  138.                                     be the same.  For example, a compressed file could be
  139.                                     named FILE.EX$ as the source, and FILE.EXE as the
  140.                                     destination.  Components are unchanged.
  141.  
  142.                                     This call is made every time a file is about to be
  143.                                     copied.  Override this section if you want to display
  144.                                     messages in a window created by icm_startCopy or if you
  145.                                     want to use your own copying code.  For example, if you
  146.                                     encode your main .EXE, but not the rest of the files,
  147.                                     you can check to see if the current file is encoded, and
  148.                                     if it is, you decode it (and copy) and return
  149.                                     ir_SkipSection, and if it isn't encoded you ignore it and
  150.                                     return ir_Continue.  You can even do this:  decode the
  151.                                     source file to a temporary file (in Windows temp directory),
  152.                                     change Src to reflect this new source file, and return
  153.                                     ir_Continue.  EDI Install will then copy (decompressing if
  154.                                     needed) the file!  So you can have encoding without losing
  155.                                     the built-in compression!  This is also a good place to
  156.                                     add special version checking code if the default mechanisms
  157.                                     are not sufficient.  If you return ir_AbortInstall, you
  158.                                     should also display an error dialog box.
  159.  
  160.  
  161.                 icm_EndCopy         Src, Dest and Components are unchanged.
  162.  
  163.                                     This call is made after any files get copied.  Use this
  164.                                     call to clean up the setup procedure you accessed in
  165.                                     icm_StartCopy.
  166.  
  167.  
  168.                 icm_PMGroup         Src contains the default name for the Program Manager
  169.                                     group.  Dest and Components are unchanged.
  170.  
  171.                                     This call is made before the PM Group dialog box is
  172.                                     displayed.  You may override it with your own dialog box
  173.                                     if you don't like the default dialog box.
  174.  
  175.  
  176.                 icm_ExtraStuff      Src, Dest and Components are unchanged.
  177.  
  178.                                     This call is made once the installation has successfully
  179.                                     been completed, but before the user has been informed.  You
  180.                                     may use it if you need to take care of extra stuff such as
  181.                                     modifying the CONFIG.SYS or AUTOEXEC.BAT files.
  182.  
  183.  
  184.                 icm_EndDlgGood      Src, Dest and Components are unchanged.
  185.                 icm_EndDlgBad
  186.                                     These are called before the last dialog box ("Installation
  187.                                     complete/incomplete") is displayed.  You can override it
  188.                                     if you prefer to display your own dialog box or if you
  189.                                     need special "clean up" procedures depending on success
  190.                                     (icm_EndDlgGood) or failure (icm_EndDlgBad).  If you handle
  191.                                     the dialog, return ir_SkipSection.  If not, return
  192.                                     ir_Continue.  Note that these calls will NOT be made if
  193.                                     the installation was aborted BEFORE the file copy process
  194.                                     was started (prior to the first icm_FileCopy call).
  195.  
  196.  
  197.                 icm_EndInstall      Src, Dest and Components are unchanged.
  198.  
  199.                                     This call is made before the installer quits.  You
  200.                                     can do your general cleanup here since it will always get
  201.                                     called, regardless of the success/failure/cancelled
  202.                                     situation.  Return values are ignored.
  203.  
  204.   Src           Points to a 256 byte buffer (including NULL terminater) containing the
  205.                 source path or the source file, depending on the value of Code.  It contains
  206.                 the source file if Code is equal to icm_FileCopy, and the source path for
  207.                 everything else.  You may modify this value any time you like.  It could
  208.                 potentially be changed every time EDI Install needs a new disk, since the
  209.                 user is asked for an alternate path.
  210.  
  211.  
  212.   Dest          Points to a 256 byte buffer (including null terminater) containing the
  213.                 destination path or the destination file, depending on the value of Code.
  214.                 It contains the destination file if Code is equal to icm_FileCopy, and the
  215.                 destination path for everything else.  You may modify this value any time you
  216.                 like, although that's not a very good idea.
  217.  
  218.  
  219.   Components    Points to a 32-Bit value (a longint or double word) representing 32 separate
  220.                 values.  Technically it's a bitpacked array of 32, bit sized elements.  So each
  221.                 bit represents a component (up to a maximum of 32 components).  If the bit is
  222.                 on, the component is selected, if it's off, it is unselected.  For example,
  223.                 to determine if a particalur component is selected or not, in Turbo Pascal you
  224.                 would do:
  225.  
  226.                     If (((1 SHL Comp) And Components) = (1 SHL MyComponent)) Then
  227.  
  228.                 Where "MyComponent" is the component you want to check for.  You may modify
  229.                 this value any time you like.
  230.  
  231.  
  232.   Returns
  233.   ~~~~~~~
  234.  
  235.   Possible return values are:
  236.  
  237.                 ir_Continue         Continues with the the installation.
  238.  
  239.                 ir_SkipSection      Skips the applicable section (icm_Setup, icm_Components,
  240.                                     icm_PMGroup, icm_EndDlgGood, icm_EndDlgBad).
  241.  
  242.                 ir_AbortInstall     Aborts the installation and displays a message box.
  243.  
  244.  
  245.  
  246.   Notes
  247.   ~~~~~
  248.  
  249.   If you need to use new dialogs, add them to the DLL, not the installer.  If you add them to
  250.   the installer you are likely to cause problems during multiple disk installations.  Also,
  251.   you should attempt to maintain the same "look and feel" through the dialogs, and use the
  252.   icons located in INSTALL.EXE whenever possible (use LoadIcon(Instance, xxx) to load an icon
  253.   form the installer.  There aren't any restrictions on what you can and cannot do in the
  254.   DLL provided you follow standard DLL rules.  You don't need to lock or fix the DLL since
  255.   the installer will copy it to a temporary file on the hard disk.  It will be deleted once
  256.   the installation is complete.
  257.  
  258.   If there's something you want to do but you can seem to be able to with the current codes,
  259.   let us know and we'll see what we can do about.  If you aren't too sure about what you need
  260.   to do or you don't want to write the DLL yourself, we can create a custom DLL for a reasonable
  261.   fee.
  262. }
  263.  
  264.  
  265. { The following is a skeleton procedure.  Fill it in to handle your needs. }
  266.  
  267.  
  268.   Function InstallDLLProc(Instance : THandle;  Code : Integer;  Src, Dest : PChar;
  269.                           Var Components : LongInt) : Integer;  Export;
  270.   Begin
  271.     InstallDLLProc := ir_Continue;
  272.  
  273.     Case Code Of
  274.       icm_Setup       : OutputDebugString('Setup');
  275.       icm_Setup2      : OutputDebugString('Setup2');
  276.       icm_Components  : OutputDebugString('Components');
  277.       icm_Components2 : OutputDebugString('Components2');
  278.       icm_StartCopy   : OutputDebugString('StartCopy');
  279.       icm_FileCopy    : OutputDebugString(Src);
  280.       icm_EndCopy     : OutputDebugString('EndCopy');
  281.       icm_PMGroup     : OutputDebugString(Src);
  282.       icm_ExtraStuff  : OutputDebugString('ExtraStuff');
  283.       icm_EndDlgGood  : OutputDebugString('EndDlgGood');
  284.       icm_EndDlgBad   : OutputDebugString('EndDlgBad');
  285.       icm_EndInstall  : OutputDebugString('EndInstall');
  286.     End;
  287.   End;
  288.  
  289.  
  290.  
  291. Exports
  292.   InstallDLLProc Index 100;
  293.  
  294.  
  295. Begin
  296. End.
  297.