Subversion Repositories autosfx

Rev

Blame | Last modification | View Log | RSS feed

  1. (******************************************************************)
  2. (* SFX for DelZip v1.9                                            *)
  3. (* Copyright 2002-2004, 2008                                      *)
  4. (*                                                                *)
  5. (* written by Markus Stephany                                     *)
  6. (* modified by Russell Peters, Roger Aelbrecht
  7.   This library is free software; you can redistribute it and/or
  8.   modify it under the terms of the GNU Lesser General Public
  9.   License as published by the Free Software Foundation; either
  10.   version 2.1 of the License, or (at your option) any later version.
  11.  
  12.   This library is distributed in the hope that it will be useful,
  13.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.   Lesser General Public License (licence.txt) for more details.
  16.  
  17.   You should have received a copy of the GNU Lesser General Public
  18.   License along with this library; if not, write to the Free Software
  19.   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  20.  
  21.   contact: problems AT delphizip DOT org
  22.   updates: http://www.delphizip.org
  23.  
  24.   modified 30-Jan-2008
  25. ---------------------------------------------------------------------------*)
  26. unit ZMSFXDefs19;
  27.  
  28. {
  29. this unit contains most definitions, constants and types used
  30. by the sfx binary of delzip.
  31.  
  32. }
  33.  
  34. interface
  35.  
  36. uses
  37.   Messages, Windows;
  38.  
  39. //{$I DELVER.INC}
  40. {$I ..\ZipVers19.inc}
  41.  
  42. { Dialog Control-IDs }
  43. const
  44.   // buttons !! don't change the order of the first two buttons (SFXDialogs.pas, FileExistsDialogProc)
  45.   ID_BTN_YES = 1; // yes/ok-buttons
  46.   ID_BTN_NO = 2; // no/cancel-buttons
  47.  
  48.   ID_BTN_ABOUT = 103; // about-button
  49.   ID_BTN_BROWSE = 104; // browse for extraction path
  50.   ID_BTN_SHOWFILES = 105; // enlarge dialog to show files list box
  51.  
  52.   // edit box
  53.   ID_EDITBOX = 201; // path/password edit
  54.  
  55.   // check boxes
  56.   ID_CB_NOASK = 301; // file already exist : don't ask again checkbox
  57.   ID_CB_RUN = 302; // after extraction, run/install...
  58.  
  59.   // files list view
  60.   ID_LV_FILES = 401; // file list view
  61.  
  62.   // lines/edges (gui enhancements)
  63.   ID_EDGE_BOTTOM = 502; // lower
  64.  
  65.   // other STATICs
  66.   ID_ST_EXTRACTTO = 601; // "extract to"
  67.   ID_ST_OVWGROUP = 602; // "existing files:..."
  68.   ID_ST_FILES = 501; // "Files:"
  69.  
  70.   // radio buttons  !! don't change the order!
  71.   ID_RB_OVERWRITE = 701; // overwrite existing files
  72.   ID_RB_SKIP = 702; // do not overwrite existing files
  73.   ID_RB_CONFIRM = 703; // ask before overwriting
  74.  
  75.   // progress bar
  76.   ID_PRG_EXTRACT = 801; // extraction progress
  77.  
  78.   // language combo
  79.   ID_LANG_COMBO = 901;
  80.   ID_LANG_SELECT = 903;
  81.  
  82. const
  83.   // max password length
  84.   MAX_PASSWORD = 80;
  85.    
  86. const
  87.   // request value for Dialogs for setting strings
  88.   SFX_DLG_MAIN = 1;//$400;
  89.   SFX_DLG_FILE = 2;//$800;
  90.   SFX_DLG_PWRD = 3;//$C00;
  91.   SFX_DLG_LANG = 4;
  92.  
  93. //  SFX_DLG_MASK = $C00;
  94.  
  95. type
  96.   // crc table type
  97.   TCRC32Table = array[0..256] of Cardinal;
  98.  
  99. const
  100.   // window size--must be a power OF two, and at least 32k
  101.   WSIZE = 32768;
  102.   RAND_HEAD_LEN = 12;
  103.   CRC_MASK = HIGH(Cardinal);
  104. //  CRC_MASK = {$IFNDEF DELPHI3UP}Cardinal(-1){$ELSE}$FFFFFFFF{$ENDIF};
  105.   SFXSpanTypeNone = 0;
  106.   SFXSpanTypeSpanned = 1;
  107.   SFXSpanTypeMultiVol = 2;
  108.   SFXSpanTypeUnknown = -1;
  109.  
  110. const
  111.   { DEFLATE stuff }
  112.   // Tables for deflate from PKZIP's appnote.txt.
  113.  
  114.   // Copy lengths FOR literal codes 257..285
  115.   cplens: array[0..30] of word = (3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17,
  116.     19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0);
  117.  
  118.   // Copy offsets FOR distance codes 0..29
  119.   cpdist: array[0..29] of word = (1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
  120.     65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
  121.     8193, 12289, 16385, 24577);
  122.  
  123.   // Extra bits FOR literal codes 257..285
  124.   cplext: array[0..30] of byte = (0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2,
  125.     2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99); { 99==invalid }
  126.  
  127.   // Extra bits FOR distance codes
  128.   cpdext: array[0..29] of byte = (0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5,
  129.     5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13);
  130.  
  131.   // AND'ing with mask[n] masks the lower n bits
  132.   maskr: array[0..16] of word = ($0000, $0001, $0003, $0007, $000F, $001F,
  133.     $003F, $007F, $00FF, $01FF, $03FF, $07FF, $0FFF, $1FFF, $3FFF, $7FFF, $FFFF);
  134.  
  135.   lbits = 9;
  136.   dbits = 6;
  137.   N_MAX = 288;
  138.  
  139. type
  140.   PT = ^Thuft;
  141.   Thuft = packed record
  142.     e,
  143.     b: shortint;
  144.     n: word;
  145.     Next: PT;
  146.   end;
  147.  
  148.   BufPtr = ^BufType;
  149.   BufType = array[0..WSIZE] of byte;
  150.  
  151. const
  152.   { SHBrowseForFolder definitions and functions }
  153.   BFFM_INITIALIZED = 1;
  154. {$IFDEF UNICODE}
  155.   BFFM_SETSELECTION = WM_USER + 103;
  156. {$ELSE}
  157.   BFFM_SETSELECTION = WM_USER + 102;
  158. {$ENDIF}
  159.   BFFM_SELCHANGED = 2;
  160.   BIF_RETURNONLYFSDIRS = 1;
  161.   BIF_NEWDIALOGSTYLE = $40;
  162.   BIF_EDITBOX = $10;
  163.   BIF_USENEWUI = (BIF_NEWDIALOGSTYLE or BIF_EDITBOX);
  164.  
  165. type
  166.   // browsecallback
  167.   TFNBFFCallBack = function(Wnd: HWND; uMsg: UINT;
  168.     lParam, lpData: LPARAM): integer; stdcall;
  169.  
  170.   // TSHItemID -- Item ID
  171.   TSHItemID = packed record { mkid }
  172.     cb: word; { Size of the ID (including cb itself) }
  173.     abID: array[0..0] of byte; { The item ID (variable length) }
  174.   end;
  175.  
  176.   // TItemIDList -- List if item IDs (combined with 0-terminator)
  177.   pItemIDList = ^TItemIDList;
  178.   TItemIDList = packed record { idl }
  179.     mkid: TSHItemID;
  180.   end;
  181.  
  182.   TBrowseInfo = packed record
  183.     hwndOwner: HWND;
  184.     pidlRoot: pItemIDList;
  185. //    pszDisplayName: pAnsiChar; { Return display name of item selected. }
  186. //    lpszTitle: pAnsiChar; { text to go in the banner over the tree. }
  187.     pszDisplayName: pChar; { Return display name of item selected. }
  188.     lpszTitle: pChar; { text to go in the banner over the tree. }
  189.     ulFlags: UINT; { Flags that control the return stuff }
  190.     lpfn: TFNBFFCallBack;
  191.     lParam: LPARAM; { extra info that's passed back in callbacks }
  192.     iImage: integer; { output var: where to return the Image index. }
  193.   end;
  194.  
  195.  
  196. //  {$IFDEF DELPHI3UP}
  197.   // Lucjan Lukasik
  198.   { IMalloc interface }
  199.  
  200.   IMalloc = interface(IUnknown)
  201.     ['{00000002-0000-0000-C000-000000000046}']
  202.     function Alloc(cb: longint): Pointer; stdcall;
  203.     function Realloc(pv: Pointer; cb: longint): Pointer; stdcall;
  204.     procedure Free(pv: Pointer); stdcall;
  205.     function GetSize(pv: Pointer): longint; stdcall;
  206.     function DidAlloc(pv: Pointer): integer; stdcall;
  207.     procedure HeapMinimize; stdcall;
  208.   end;
  209. //  {$ENDIF}
  210.  
  211.   PSHFileInfo = ^TSHFileInfo;
  212.   TSHFileInfo = record
  213.     hIcon: HICON;
  214.     iIcon: Integer;
  215.     dwAttributes: Cardinal;
  216.     szDisplayName: array [0..MAX_PATH-1] of Char;
  217.     szTypeName: array [0..79] of Char;
  218.   end;
  219. const
  220.   SHGFI_SYSICONINDEX      = $000004000;
  221.   SHGFI_SELECTED          = $000010000;
  222.   SHGFI_SMALLICON         = $000000001;
  223.   SHGFI_SHELLICONSIZE     = $000000004;
  224.   SHGFI_USEFILEATTRIBUTES = $000000010;
  225.  
  226. //{$ENDIF}
  227. const
  228.   // progressbar defs
  229.   PBM_SETRANGE = WM_USER + 1;
  230.   PBM_SETPOS = WM_USER + 2;
  231.  
  232.   { strings }
  233.   Chr_DirSep = '\';
  234.  
  235.   {! do not localize dialog resource names below !}
  236.   { dialog resource names }
  237.   Str_Dlg_Main = 'MAINDIALOG'; // main dialog res
  238.   Str_Dlg_Password = 'PASSWD'; // password input box
  239.   Str_Dlg_FileExists = 'FILEEXIST'; // overwrite file confirmation dialog
  240.   Str_Dlg_Language = 'LANGS'; // languages dialog res
  241.   {! do not localize dialog resource names above !}
  242.  
  243. // stuff different between delphi versions
  244. type
  245. //{$IFDEF DELPHI4UP} // may be incorrect (DELPHI3UP?)
  246. //{$IFDEF VERD4up}
  247.   TWriteFileWritten = Cardinal;
  248. //{$ELSE}
  249. //  TWriteFileWritten = Integer;
  250. //{$ENDIF}
  251.  
  252. // stuff not defined in delphi 2
  253. //{$I missing_types.inc}
  254.  
  255.  
  256. // list view definitions
  257. const
  258.   LVFI_STRING             = $0002;
  259.  
  260.   LVCFMT_LEFT             = $0000;
  261.   LVCFMT_RIGHT            = $0001;
  262.   LVCFMT_CENTER           = $0002;
  263.   LVCFMT_JUSTIFYMASK      = $0003;
  264.  
  265.   LVCF_FMT                = $0001;
  266.   LVCF_WIDTH              = $0002;
  267.   LVCF_TEXT               = $0004;
  268.   LVCF_SUBITEM            = $0008;
  269.   LVCF_IMAGE              = $0010;
  270.   LVCF_ORDER              = $0020;
  271.  
  272.   LVSIL_SMALL             = 1;
  273.  
  274.   LVS_EX_FULLROWSELECT    = $00000020;
  275.  
  276.   LVN_FIRST               = 0-100;
  277.   LVN_ITEMCHANGING        = LVN_FIRST-0;
  278.   LVN_ITEMCHANGED         = LVN_FIRST-1;
  279.  
  280.   LVM_FIRST               = $1000;
  281.   LVM_SETIMAGELIST        = LVM_FIRST + 3;
  282.   LVM_GETITEMCOUNT        = LVM_FIRST + 4;
  283.   LVM_GETITEMA            = LVM_FIRST + 5;
  284.   LVM_GETITEMW            = LVM_FIRST + 75;
  285.   LVM_SETITEMA            = LVM_FIRST + 6;
  286.   LVM_SETITEMW            = LVM_FIRST + 76;
  287.   LVM_INSERTITEMA         = LVM_FIRST + 7;
  288.   LVM_INSERTITEMW         = LVM_FIRST + 77;
  289.   LVM_FINDITEMA           = LVM_FIRST + 13;
  290.   LVM_FINDITEMW           = LVM_FIRST + 83;
  291.   LVM_ENSUREVISIBLE       = LVM_FIRST + 19;
  292.   LVM_SETCOLUMNA          = LVM_FIRST + 26;
  293.   LVM_SETCOLUMNW          = LVM_FIRST + 96;
  294.   LVM_INSERTCOLUMNA       = LVM_FIRST + 27;
  295.   LVM_INSERTCOLUMNW       = LVM_FIRST + 97;
  296.   LVM_SETITEMSTATE        = LVM_FIRST + 43;
  297.   LVM_GETITEMSTATE        = LVM_FIRST + 44;
  298.   LVM_GETITEMTEXTA        = LVM_FIRST + 45;
  299.   LVM_GETITEMTEXTW        = LVM_FIRST + 115;
  300.   LVM_GETSELECTEDCOUNT    = LVM_FIRST + 50;
  301.   LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54;
  302. {$IFDEF UNICODE}
  303.   LVM_GETITEM                   = LVM_GETITEMW;
  304.   LVM_SETITEM                   = LVM_SETITEMW;
  305.   LVM_INSERTITEM                    = LVM_INSERTITEMW;
  306.   LVM_FINDITEM                        = LVM_FINDITEMW;
  307.   LVM_SETCOLUMN                       = LVM_SETCOLUMNW;
  308.   LVM_INSERTCOLUMN                = LVM_INSERTCOLUMNW;
  309.   LVM_GETITEMTEXT                   = LVM_GETITEMTEXTW;
  310. {$ELSE}
  311.   LVM_GETITEM                   = LVM_GETITEMA;
  312.   LVM_SETITEM                   = LVM_SETITEMA;
  313.   LVM_INSERTITEM                    = LVM_INSERTITEMA;
  314.   LVM_FINDITEM                        = LVM_FINDITEMA;
  315.   LVM_SETCOLUMN                       = LVM_SETCOLUMNA;
  316.   LVM_INSERTCOLUMN                = LVM_INSERTCOLUMNA;
  317.   LVM_GETITEMTEXT                   = LVM_GETITEMTEXTA;
  318. {$ENDIF}
  319.  
  320.   CCM_FIRST               = $2000;      { Common control shared messages }
  321.   CCM_SETUNICODEFORMAT    = CCM_FIRST + 5;
  322.   CCM_GETUNICODEFORMAT    = CCM_FIRST + 6;
  323.  
  324. type
  325.   PLVColumn = ^TLVColumn;
  326.   TLVCOLUMN = packed record
  327.     mask: Cardinal;
  328.     fmt: Integer;
  329.     cx: Integer;
  330.     pszText: PChar;
  331.     cchTextMax: Integer;
  332.     iSubItem: Integer;
  333.     iImage: Integer;
  334.     iOrder: Integer;
  335.   end;
  336.  
  337.   PLVFindInfo = ^TLVFindInfo;
  338.   TLVFindInfo = packed record
  339.     flags: UINT;
  340.     psz: PChar;
  341.     lParam: LPARAM;
  342.     pt: TPoint;
  343.     vkDirection: UINT;
  344.   end;
  345.  
  346.  
  347. const
  348.   LVIF_TEXT               = $0001;
  349.   LVIF_IMAGE              = $0002;
  350.   LVIF_PARAM              = $0004;
  351.   LVIF_STATE              = $0008;
  352.  
  353.   LVIS_SELECTED           = $0002;
  354.  
  355.   ICC_LISTVIEW_CLASSES    = $00000001; // listview, header
  356.   ICC_TREEVIEW_CLASSES    = $00000002; // treeview, tooltips
  357.   ICC_BAR_CLASSES         = $00000004; // toolbar, statusbar, trackbar, tooltips
  358.   ICC_TAB_CLASSES         = $00000008; // tab, tooltips
  359.   ICC_UPDOWN_CLASS        = $00000010; // updown
  360.   ICC_PROGRESS_CLASS      = $00000020; // progress
  361.   ICC_HOTKEY_CLASS        = $00000040; // hotkey
  362.   ICC_ANIMATE_CLASS       = $00000080; // animate
  363.   ICC_WIN95_CLASSES       = $000000FF;
  364.   ICC_DATE_CLASSES        = $00000100; // month picker, date picker, time picker, updown
  365.   ICC_USEREX_CLASSES      = $00000200; // comboex
  366.   ICC_COOL_CLASSES        = $00000400; // rebar (coolbar) control
  367.   ICC_STANDARD_CLASSES    = $00004000;
  368.  
  369. type
  370.   PLVItem = ^TLVItem;
  371.   TLVITEM = packed record
  372.     mask: Cardinal;
  373.     iItem: Integer;
  374.     iSubItem: Integer;
  375.     state: Cardinal;
  376.     stateMask: Cardinal;
  377.     pszText: PChar;
  378.     cchTextMax: Integer;
  379.     iImage: Integer;
  380.     lParam: LPARAM;
  381.     iIndent: Integer;
  382.  
  383. //    iGroupId: Integer;
  384. //    cColumns: Integer;{ tile view columns }
  385. //    puColumns: PUINT;
  386.   end;
  387.  
  388.   PNMListView = ^TNMListView;
  389.   TNMListView = packed record
  390.     hdr: TNMHDR;
  391.     iItem: Integer;
  392.     iSubItem: Integer;
  393.     uNewState: UINT;
  394.     uOldState: UINT;
  395.     uChanged: UINT;
  396.     ptAction: TPoint;
  397.     lParam: LPARAM;
  398.   end;
  399.  
  400.   PCCInitCommonControlsEx = ^TCCInitCommonControlsEx;
  401.   TCCInitCommonControlsEx = packed record
  402.     dwSize: DWORD;
  403.     dwICC: DWORD;
  404.   end;
  405.  
  406.   { api definitions }
  407.   // initialize common controls (progress bar)
  408. //procedure InitCommonControls; stdcall; external 'comctl32.dll' Name 'InitCommonControls';
  409. function InitCommonControlsEx(const IntCtrls : PCCINITCOMMONCONTROLSEX): LongBool; stdcall;
  410.   external 'comctl32.dll' Name 'InitCommonControlsEx';
  411.  
  412. {$IFDEF UNICODE}
  413. // needed by ShBrowseForFolder
  414. function SHBrowseForFolder(var lpbi: TBrowseInfo): pItemIDList; stdcall;
  415.   external 'shell32.dll' Name 'SHBrowseForFolderW';
  416.  
  417. function SHGetPathFromIDList(pidl: pItemIDList; pszPath: PChar): BOOL;
  418.   stdcall; external 'shell32.dll' Name 'SHGetPathFromIDListW';
  419. {$ELSE}
  420. function SHBrowseForFolder(var lpbi: TBrowseInfo): pItemIDList; stdcall;
  421.   external 'shell32.dll' Name 'SHBrowseForFolderA';
  422.  
  423. function SHGetPathFromIDList(pidl: pItemIDList; pszPath: PAnsiChar): BOOL;
  424.   stdcall; external 'shell32.dll' Name 'SHGetPathFromIDListA';
  425. {$ENDIF}
  426.  
  427. //{$IFDEF DELPHI3UP}
  428. function SHGetMalloc(var ppMalloc: IMalloc): HResult; stdcall;
  429.   external 'shell32.dll' Name 'SHGetMalloc'; // Lucjan Lukasik
  430. //{$ENDIF}
  431.  
  432. {$IFDEF UNICODE}
  433. function SHGetFileInfo(pszPath: PChar; dwFileAttributes: DWORD;
  434.   var psfi: TSHFileInfo; cbFileInfo, uFlags: Cardinal): DWORD; stdcall;
  435.   external 'shell32.dll' name 'SHGetFileInfoW';
  436. {$ELSE}
  437. function SHGetFileInfo(pszPath: PAnsiChar; dwFileAttributes: DWORD;
  438.   var psfi: TSHFileInfo; cbFileInfo, uFlags: Cardinal): DWORD; stdcall;
  439.   external 'shell32.dll' name 'SHGetFileInfoA';
  440. {$ENDIF}
  441.  
  442. function ShellExecute(hWnd: HWND; Operation, FileName, Parameters, Directory: PChar;
  443.   ShowCmd: integer): HINST; stdcall; external 'shell32.dll' Name 'ShellExecuteA';
  444.  
  445. implementation
  446.  
  447. end.
  448.