⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abfcifdi.pas

📁 Lazarus is a free and open source development tool for the FreePascal Compiler. The purpose of the p
💻 PAS
📖 第 1 页 / 共 2 页
字号:
(* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is TurboPower Abbrevia
 *
 * The Initial Developer of the Original Code is
 * TurboPower Software
 *
 * Portions created by the Initial Developer are Copyright (C) 1997-2002
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * ***** END LICENSE BLOCK ***** *)

{*********************************************************}
{* ABBREVIA: AbFciFdi.pas 3.05                           *}
{*********************************************************}
{* ABBREVIA: Cabinet DLL wrapper                         *}
{* Based on info from the FCI/FDI Library Description,   *}
{* included in the Microsoft Cabinet SDK                 *}
{*********************************************************}

unit AbFciFdi;

{$mode delphi}

interface

uses
  typesarchive, //!! MVC for BOOL
  dynlibs, // loadlibrary
{$ifdef mswindows}
  Windows,
{$endif}  
  SysUtils, Classes;

const
  CabinetDLL  = 'cabinet.dll';
  cpuUnknown  = -1;
  cpu80286    = 0;
  cpu80386    = 1;
  cpuDefault  = cpuUnknown;


type
  {FDI errors}
  FDIError =
    (FDIError_None,            FDIError_Cabinet_Not_Found,
     FDIError_Not_A_Cabinet,   FDIError_Unknown_Cabinet_Version,
     FDIError_Corrupt_Cabinet, FDIError_Alloc_Fail,
     FDIError_Bad_Compr_Type,  FDIError_MDI_Fail,
     FDIError_Target_File,     FDIError_Reserve_Mismatch,
     FDIError_Wrong_Cabinet,   FDIError_User_Abort);

  {FCI errors}
  FCIError =
    (FCIError_NONE,      FCIError_Open_SRC,
     FCIError_Read_SRC,  FCIError_Alloc_Fail,
     FCIError_Temp_File, FCIError_Bad_Compr_Type,
     FCIError_Cab_File,  FCIError_User_Abort,
     FCIERRor_MCI_Fail);

  {FDI notifications}
  FDINotificationType =
    (FDINT_Cabinet_Info, FDINT_Partial_File,
     FDINT_Copy_File,    FDINT_Close_File_Info,
     FDINT_Next_Cabinet, FDINT_Enumerate);

  {FDI/FCI error structure}
  PCabErrorRecord = ^CabErrorRecord;
  CabErrorRecord  = record
    ErrorCode     : Integer;
    ErrorType     : Integer;
    ErrorPresent  : Boolean;
  end;

  {FDI cabinet information structure}
  PFDICabInfo = ^FDICabInfo;
  FDICabInfo  = record
    cbCabinet : Longint;
    cFolders  : Word;
    cFiles    : Word;
    setID     : Word;
    iCabinet  : Word;
    fReserve  : BOOL;
    hasprev   : BOOL;
    hasnext   : BOOL;
  end;

  {FCI cabinet information structure}
  PFCICabInfo = ^FCICabInfo;
  FCICabInfo  = record
    cb                    : Longint;
    cbFolderThresh        : Longint;
    cbReserveCFHeader     : Integer;
    cbReserveCFFolder     : Integer;
    cbReserveCFData       : Integer;
    iCab                  : Integer;
    iDisk                 : Integer;
    fFailOnIncompressible : Integer;
    setID                 : Word;
    szDisk                : array[0..255] of Char;
    szCab                 : array[0..255] of Char;
    szCabPath             : array[0..255] of Char;
  end;

  {FDI notification structure}
  PFDINotification = ^FDINotification;
  FDINotification  = record
    cb       : Longint;
    psz1     : PChar;
    psz2     : PChar;
    psz3     : PChar;
    pv       : Pointer;
    hf       : Integer;
    date     : Word;
    time     : Word;
    attribs  : Word;
    setID    : Word;
    iCabinet : Word;
    iFolder  : Word;
    fdie     : FDIERROR;
  end;

  {misc defines}
  HFDI    = Pointer;
  HFCI    = Pointer;
  FARPROC = Pointer;


{== Cabinet DLL routine prototypes ==========================================}
type
  TFDICreate =
    function (pfnalloc, pfnfree, pfnopen, pfnread, pfnwrite, pfnclose,
      pfnseek : FARPROC; cpuType  : Integer; pError : PCabErrorRecord) : HFDI;
      cdecl;
{----------------------------------------------------------------------------}
  TFDIIsCabinet =
    function(hfdi : HFDI; hf : Integer; pfdici : PFDICabInfo) : Boolean;
      cdecl;
{----------------------------------------------------------------------------}
  TFDICopy =
    function(hfdi : HFDI; pszCabinet, pszCabPath : PChar;
      flags : Integer; pfnfdin, pfnfdid : FARPROC; Archive : Pointer) : Boolean;
      cdecl;
{----------------------------------------------------------------------------}
  TFDIDestroy =
    function(hfdi : HFDI) : Boolean;
      cdecl;
{----------------------------------------------------------------------------}
  TFCICreate =
    function(pError : PCabErrorRecord; pfnfcifp, pfnalloc, pfnfree,
      pfnopen, pfnread, pfnwrite, pfnclose, pfnseek, pfndelete,
      pfnfcigtf : FARPROC; pccab : PFCICabInfo; Archive : Pointer) : HFCI;
      cdecl;
{----------------------------------------------------------------------------}
  TFCIAddFile =
    function(hfci : HFCI; pszFilePath, pszFileName : PChar;
      fExecute : Boolean; pfnfcignc, pfnfcis, pfnfcigoi : FARPROC;
      typeCompress : Word) : Boolean;
      cdecl;
{----------------------------------------------------------------------------}
  TFCIFlushCabinet =
    function(hfci : HFCI; fGetNextCab : Boolean;
      pfnfcignc, pfnfcis : FARPROC) : Boolean;
      cdecl;
{----------------------------------------------------------------------------}
  TFCIFlushFolder =
    function(hfci : HFCI; pfnfcignc, pfnfcis : FARPROC) : Boolean;
      cdecl;
{----------------------------------------------------------------------------}
  TFCIDestroy =
    function(hfci : HFCI) : Boolean;
      cdecl;


{== DLL routine wrappers ====================================================}
function FDICreate(pfnalloc, pfnfree, pfnopen, pfnread,
  pfnwrite, pfnclose, pfnseek : FARPROC;
  cpuType  : Integer; pError : PCabErrorRecord) : HFDI;
  {returns an FDI context for opening an existing cabinet}
  {  pfnalloc - heap allocation callback function }
  {  pfnfree  -  heap deallocation callback function }
  {  pfnopen  -  open file callback function }
  {  pfnwrite - write file callback function }
  {  pfnclose - close file callback function }
  {  pfnseek  - reposition file pointer callback function }
  {  cpuType  -  -1: unknown, 0: 80286, 1: 80386 }
  {  pError   -  pointer to error record }
{----------------------------------------------------------------------------}
function FDIIsCabinet(hfdi : HFDI; hf : Integer;
  pfdici : PFDICabInfo) : Boolean;
  {checks cabinet file for validity}
  {  hfdi   - FDI context }
  {  hf     - cabinet file handle }
  {  pfdici - pointer to FDI cabinet info structure }
{----------------------------------------------------------------------------}
function FDICopy(hfdi : HFDI; pszCabinet, pszCabPath : PChar;
  flags : Integer; pfnfdin, pfnfdid : FARPROC;
  Archive : Pointer) : Boolean;
  {enumerates every file in the cabinet.  The callback function}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -