home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / tools / install / instpro / samples / instlib.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1994-05-26  |  16.4 KB  |  340 lines

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