unit Chilkat.Mht;

{
  Pascal wrapper for Chilkat Mht.
  Auto-generated by PascalWrapperGenerator -- do not edit manually.
}

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}

interface

uses
  SysUtils,
  Chilkat.Base;

type

  { TMht wraps CkMht via the C bridge layer. }
  TMht = class(TChilkatBase)
  private
    FOnAbortCheck: TChilkatAbortCheckEvent;
    FOnPercentDone: TChilkatPercentDoneEvent;
    FOnProgressInfo: TChilkatProgressInfoEvent;
    function  GetLastErrorHtml: string;
    function  GetLastErrorText: string;
    function  GetLastErrorXml: string;
    function  GetVersion: string;
    function  GetDebugLogFilePath: string;
    procedure SetDebugLogFilePath(AValue: string);
    function  GetVerboseLogging: Boolean;
    procedure SetVerboseLogging(AValue: Boolean);
    function  GetLastMethodSuccess: Boolean;
    procedure SetLastMethodSuccess(AValue: Boolean);
    function  GetBaseUrl: string;
    procedure SetBaseUrl(AValue: string);
    function  GetConnectTimeout: Integer;
    procedure SetConnectTimeout(AValue: Integer);
    function  GetDebugHtmlAfter: string;
    procedure SetDebugHtmlAfter(AValue: string);
    function  GetDebugHtmlBefore: string;
    procedure SetDebugHtmlBefore(AValue: string);
    function  GetEmbedImages: Boolean;
    procedure SetEmbedImages(AValue: Boolean);
    function  GetEmbedLocalOnly: Boolean;
    procedure SetEmbedLocalOnly(AValue: Boolean);
    function  GetFetchFromCache: Boolean;
    procedure SetFetchFromCache(AValue: Boolean);
    function  GetHeartbeatMs: Integer;
    procedure SetHeartbeatMs(AValue: Integer);
    function  GetIgnoreMustRevalidate: Boolean;
    procedure SetIgnoreMustRevalidate(AValue: Boolean);
    function  GetIgnoreNoCache: Boolean;
    procedure SetIgnoreNoCache(AValue: Boolean);
    function  GetNoScripts: Boolean;
    procedure SetNoScripts(AValue: Boolean);
    function  GetNtlmAuth: Boolean;
    procedure SetNtlmAuth(AValue: Boolean);
    function  GetNumCacheLevels: Integer;
    procedure SetNumCacheLevels(AValue: Integer);
    function  GetNumCacheRoots: Integer;
    function  GetPreferIpv6: Boolean;
    procedure SetPreferIpv6(AValue: Boolean);
    function  GetPreferMHTScripts: Boolean;
    procedure SetPreferMHTScripts(AValue: Boolean);
    function  GetProxy: string;
    procedure SetProxy(AValue: string);
    function  GetProxyLogin: string;
    procedure SetProxyLogin(AValue: string);
    function  GetProxyPassword: string;
    procedure SetProxyPassword(AValue: string);
    function  GetReadTimeout: Integer;
    procedure SetReadTimeout(AValue: Integer);
    function  GetRequireSslCertVerify: Boolean;
    procedure SetRequireSslCertVerify(AValue: Boolean);
    function  GetSocksHostname: string;
    procedure SetSocksHostname(AValue: string);
    function  GetSocksPassword: string;
    procedure SetSocksPassword(AValue: string);
    function  GetSocksPort: Integer;
    procedure SetSocksPort(AValue: Integer);
    function  GetSocksUsername: string;
    procedure SetSocksUsername(AValue: string);
    function  GetSocksVersion: Integer;
    procedure SetSocksVersion(AValue: Integer);
    function  GetUnpackDirect: Boolean;
    procedure SetUnpackDirect(AValue: Boolean);
    function  GetUnpackUseRelPaths: Boolean;
    procedure SetUnpackUseRelPaths(AValue: Boolean);
    function  GetUpdateCache: Boolean;
    procedure SetUpdateCache(AValue: Boolean);
    function  GetUseCids: Boolean;
    procedure SetUseCids(AValue: Boolean);
    function  GetUseFilename: Boolean;
    procedure SetUseFilename(AValue: Boolean);
    function  GetUseIEProxy: Boolean;
    procedure SetUseIEProxy(AValue: Boolean);
    function  GetUseInline: Boolean;
    procedure SetUseInline(AValue: Boolean);
    function  GetWebSiteLogin: string;
    procedure SetWebSiteLogin(AValue: string);
    function  GetWebSiteLoginDomain: string;
    procedure SetWebSiteLoginDomain(AValue: string);
    function  GetWebSitePassword: string;
    procedure SetWebSitePassword(AValue: string);
    function  GetAbortCurrent: Boolean;
    procedure SetAbortCurrent(AValue: Boolean);
    procedure SetOnAbortCheck(AValue: TChilkatAbortCheckEvent);
    procedure SetOnPercentDone(AValue: TChilkatPercentDoneEvent);
    procedure SetOnProgressInfo(AValue: TChilkatProgressInfoEvent);
  public
    constructor Create;
    destructor  Destroy; override;

    property LastErrorHtml: string read GetLastErrorHtml;
    property LastErrorText: string read GetLastErrorText;
    property LastErrorXml: string read GetLastErrorXml;
    property Version: string read GetVersion;
    property DebugLogFilePath: string read GetDebugLogFilePath write SetDebugLogFilePath;
    property VerboseLogging: Boolean read GetVerboseLogging write SetVerboseLogging;
    property LastMethodSuccess: Boolean read GetLastMethodSuccess write SetLastMethodSuccess;
    property BaseUrl: string read GetBaseUrl write SetBaseUrl;
    property ConnectTimeout: Integer read GetConnectTimeout write SetConnectTimeout;
    property DebugHtmlAfter: string read GetDebugHtmlAfter write SetDebugHtmlAfter;
    property DebugHtmlBefore: string read GetDebugHtmlBefore write SetDebugHtmlBefore;
    property EmbedImages: Boolean read GetEmbedImages write SetEmbedImages;
    property EmbedLocalOnly: Boolean read GetEmbedLocalOnly write SetEmbedLocalOnly;
    property FetchFromCache: Boolean read GetFetchFromCache write SetFetchFromCache;
    property HeartbeatMs: Integer read GetHeartbeatMs write SetHeartbeatMs;
    property IgnoreMustRevalidate: Boolean read GetIgnoreMustRevalidate write SetIgnoreMustRevalidate;
    property IgnoreNoCache: Boolean read GetIgnoreNoCache write SetIgnoreNoCache;
    property NoScripts: Boolean read GetNoScripts write SetNoScripts;
    property NtlmAuth: Boolean read GetNtlmAuth write SetNtlmAuth;
    property NumCacheLevels: Integer read GetNumCacheLevels write SetNumCacheLevels;
    property NumCacheRoots: Integer read GetNumCacheRoots;
    property PreferIpv6: Boolean read GetPreferIpv6 write SetPreferIpv6;
    property PreferMHTScripts: Boolean read GetPreferMHTScripts write SetPreferMHTScripts;
    property Proxy: string read GetProxy write SetProxy;
    property ProxyLogin: string read GetProxyLogin write SetProxyLogin;
    property ProxyPassword: string read GetProxyPassword write SetProxyPassword;
    property ReadTimeout: Integer read GetReadTimeout write SetReadTimeout;
    property RequireSslCertVerify: Boolean read GetRequireSslCertVerify write SetRequireSslCertVerify;
    property SocksHostname: string read GetSocksHostname write SetSocksHostname;
    property SocksPassword: string read GetSocksPassword write SetSocksPassword;
    property SocksPort: Integer read GetSocksPort write SetSocksPort;
    property SocksUsername: string read GetSocksUsername write SetSocksUsername;
    property SocksVersion: Integer read GetSocksVersion write SetSocksVersion;
    property UnpackDirect: Boolean read GetUnpackDirect write SetUnpackDirect;
    property UnpackUseRelPaths: Boolean read GetUnpackUseRelPaths write SetUnpackUseRelPaths;
    property UpdateCache: Boolean read GetUpdateCache write SetUpdateCache;
    property UseCids: Boolean read GetUseCids write SetUseCids;
    property UseFilename: Boolean read GetUseFilename write SetUseFilename;
    property UseIEProxy: Boolean read GetUseIEProxy write SetUseIEProxy;
    property UseInline: Boolean read GetUseInline write SetUseInline;
    property WebSiteLogin: string read GetWebSiteLogin write SetWebSiteLogin;
    property WebSiteLoginDomain: string read GetWebSiteLoginDomain write SetWebSiteLoginDomain;
    property WebSitePassword: string read GetWebSitePassword write SetWebSitePassword;
    property AbortCurrent: Boolean read GetAbortCurrent write SetAbortCurrent;

    { Event callbacks.  Return True from OnAbortCheck / OnPercentDone
      to abort the running method.  Callbacks are invoked on the
      thread that called the Chilkat method.  The HeartbeatMs
      property controls the AbortCheck frequency. }
    property OnAbortCheck: TChilkatAbortCheckEvent read FOnAbortCheck write SetOnAbortCheck;
    property OnPercentDone: TChilkatPercentDoneEvent read FOnPercentDone write SetOnPercentDone;
    property OnProgressInfo: TChilkatProgressInfoEvent read FOnProgressInfo write SetOnProgressInfo;

    procedure AddCacheRoot(const dir: string);
    procedure AddCustomHeader(const name: string; const value: string);
    procedure AddExternalStyleSheet(const url: string);
    procedure ClearCustomHeaders;
    procedure ExcludeImagesMatching(const pattern: string);
    function  GetAndSaveEML(const url_or_htmlFilepath: string; const emlPath: string): Boolean;
    function  GetAndSaveMHT(const url_or_htmlFilepath: string; const mhtPath: string): Boolean;
    function  GetAndZipEML(const url_or_htmlFilepath: string; const zipEntryFilename: string; const zipFilename: string): Boolean;
    function  GetAndZipMHT(const url_or_htmlFilepath: string; const zipEntryFilename: string; const zipFilename: string): Boolean;
    function  GetCacheRoot(index: Integer): string;
    function  GetEML(const url_or_htmlFilepath: string): string;
    function  GetMHT(const url_or_htmlFilepath: string): string;
    function  HtmlToEML(const htmlText: string): string;
    function  HtmlToEMLFile(const html: string; const emlFilename: string): Boolean;
    function  HtmlToMHT(const htmlText: string): string;
    function  HtmlToMHTFile(const html: string; const mhtFilename: string): Boolean;
    procedure RemoveCustomHeader(const name: string);
    procedure RestoreDefaults;
    function  UnpackMHT(const mhtFilename: string; const unpackDir: string; const htmlFilename: string; const partsSubDir: string): Boolean;
    function  UnpackMHTString(const mhtString: string; const unpackDir: string; const htmlFilename: string; const partsSubDir: string): Boolean;
  end;

implementation

uses
  CkDllLoader,
  Chilkat.Utils;

{ ---- C bridge function pointer types ---- }
type
  TCkMht_Create  = function(): Pointer; cdecl;
  TCkMht_Dispose = procedure(handle: Pointer); cdecl;
  TCkBridgeAbortCheckCb   = function(userData: Pointer): Integer; cdecl;
  TCkBridgePercentDoneCb  = function(pctDone: Integer; userData: Pointer): Integer; cdecl;
  TCkBridgeProgressInfoCb = procedure(name: PAnsiChar; value: PAnsiChar; userData: Pointer); cdecl;
  TCkMht_SetAbortCheckCallback   = procedure(handle: Pointer; cb: TCkBridgeAbortCheckCb; userData: Pointer); cdecl;
  TCkMht_SetPercentDoneCallback  = procedure(handle: Pointer; cb: TCkBridgePercentDoneCb; userData: Pointer); cdecl;
  TCkMht_SetProgressInfoCallback = procedure(handle: Pointer; cb: TCkBridgeProgressInfoCb; userData: Pointer); cdecl;
  TCkMht_get_LastErrorHtml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkMht_get_LastErrorText = function(handle: Pointer): PAnsiChar; cdecl;
  TCkMht_get_LastErrorXml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkMht_get_Version = function(handle: Pointer): PAnsiChar; cdecl;
  TCkMht_get_DebugLogFilePath = function(handle: Pointer): PAnsiChar; cdecl;
  TCkMht_put_DebugLogFilePath = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkMht_get_VerboseLogging = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_VerboseLogging = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_LastMethodSuccess = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_LastMethodSuccess = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_BaseUrl = function(handle: Pointer): PAnsiChar; cdecl;
  TCkMht_put_BaseUrl = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkMht_get_ConnectTimeout = function(handle: Pointer): Integer; cdecl;
  TCkMht_put_ConnectTimeout = procedure(handle: Pointer; value: Integer); cdecl;
  TCkMht_get_DebugHtmlAfter = function(handle: Pointer): PAnsiChar; cdecl;
  TCkMht_put_DebugHtmlAfter = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkMht_get_DebugHtmlBefore = function(handle: Pointer): PAnsiChar; cdecl;
  TCkMht_put_DebugHtmlBefore = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkMht_get_EmbedImages = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_EmbedImages = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_EmbedLocalOnly = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_EmbedLocalOnly = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_FetchFromCache = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_FetchFromCache = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_HeartbeatMs = function(handle: Pointer): Integer; cdecl;
  TCkMht_put_HeartbeatMs = procedure(handle: Pointer; value: Integer); cdecl;
  TCkMht_get_IgnoreMustRevalidate = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_IgnoreMustRevalidate = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_IgnoreNoCache = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_IgnoreNoCache = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_NoScripts = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_NoScripts = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_NtlmAuth = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_NtlmAuth = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_NumCacheLevels = function(handle: Pointer): Integer; cdecl;
  TCkMht_put_NumCacheLevels = procedure(handle: Pointer; value: Integer); cdecl;
  TCkMht_get_NumCacheRoots = function(handle: Pointer): Integer; cdecl;
  TCkMht_get_PreferIpv6 = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_PreferIpv6 = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_PreferMHTScripts = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_PreferMHTScripts = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_Proxy = function(handle: Pointer): PAnsiChar; cdecl;
  TCkMht_put_Proxy = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkMht_get_ProxyLogin = function(handle: Pointer): PAnsiChar; cdecl;
  TCkMht_put_ProxyLogin = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkMht_get_ProxyPassword = function(handle: Pointer): PAnsiChar; cdecl;
  TCkMht_put_ProxyPassword = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkMht_get_ReadTimeout = function(handle: Pointer): Integer; cdecl;
  TCkMht_put_ReadTimeout = procedure(handle: Pointer; value: Integer); cdecl;
  TCkMht_get_RequireSslCertVerify = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_RequireSslCertVerify = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_SocksHostname = function(handle: Pointer): PAnsiChar; cdecl;
  TCkMht_put_SocksHostname = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkMht_get_SocksPassword = function(handle: Pointer): PAnsiChar; cdecl;
  TCkMht_put_SocksPassword = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkMht_get_SocksPort = function(handle: Pointer): Integer; cdecl;
  TCkMht_put_SocksPort = procedure(handle: Pointer; value: Integer); cdecl;
  TCkMht_get_SocksUsername = function(handle: Pointer): PAnsiChar; cdecl;
  TCkMht_put_SocksUsername = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkMht_get_SocksVersion = function(handle: Pointer): Integer; cdecl;
  TCkMht_put_SocksVersion = procedure(handle: Pointer; value: Integer); cdecl;
  TCkMht_get_UnpackDirect = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_UnpackDirect = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_UnpackUseRelPaths = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_UnpackUseRelPaths = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_UpdateCache = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_UpdateCache = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_UseCids = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_UseCids = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_UseFilename = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_UseFilename = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_UseIEProxy = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_UseIEProxy = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_UseInline = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_UseInline = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_get_WebSiteLogin = function(handle: Pointer): PAnsiChar; cdecl;
  TCkMht_put_WebSiteLogin = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkMht_get_WebSiteLoginDomain = function(handle: Pointer): PAnsiChar; cdecl;
  TCkMht_put_WebSiteLoginDomain = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkMht_get_WebSitePassword = function(handle: Pointer): PAnsiChar; cdecl;
  TCkMht_put_WebSitePassword = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkMht_get_AbortCurrent = function(handle: Pointer): LongBool; cdecl;
  TCkMht_put_AbortCurrent = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkMht_AddCacheRoot = procedure(handle: Pointer; dir: PAnsiChar); cdecl;
  TCkMht_AddCustomHeader = procedure(handle: Pointer; name: PAnsiChar; value: PAnsiChar); cdecl;
  TCkMht_AddExternalStyleSheet = procedure(handle: Pointer; url: PAnsiChar); cdecl;
  TCkMht_ClearCustomHeaders = procedure(handle: Pointer); cdecl;
  TCkMht_ExcludeImagesMatching = procedure(handle: Pointer; pattern: PAnsiChar); cdecl;
  TCkMht_GetAndSaveEML = function(handle: Pointer; url_or_htmlFilepath: PAnsiChar; emlPath: PAnsiChar): LongBool; cdecl;
  TCkMht_GetAndSaveMHT = function(handle: Pointer; url_or_htmlFilepath: PAnsiChar; mhtPath: PAnsiChar): LongBool; cdecl;
  TCkMht_GetAndZipEML = function(handle: Pointer; url_or_htmlFilepath: PAnsiChar; zipEntryFilename: PAnsiChar; zipFilename: PAnsiChar): LongBool; cdecl;
  TCkMht_GetAndZipMHT = function(handle: Pointer; url_or_htmlFilepath: PAnsiChar; zipEntryFilename: PAnsiChar; zipFilename: PAnsiChar): LongBool; cdecl;
  TCkMht_GetCacheRoot = function(handle: Pointer; index: Integer): PAnsiChar; cdecl;
  TCkMht_GetEML = function(handle: Pointer; url_or_htmlFilepath: PAnsiChar): PAnsiChar; cdecl;
  TCkMht_GetMHT = function(handle: Pointer; url_or_htmlFilepath: PAnsiChar): PAnsiChar; cdecl;
  TCkMht_HtmlToEML = function(handle: Pointer; htmlText: PAnsiChar): PAnsiChar; cdecl;
  TCkMht_HtmlToEMLFile = function(handle: Pointer; html: PAnsiChar; emlFilename: PAnsiChar): LongBool; cdecl;
  TCkMht_HtmlToMHT = function(handle: Pointer; htmlText: PAnsiChar): PAnsiChar; cdecl;
  TCkMht_HtmlToMHTFile = function(handle: Pointer; html: PAnsiChar; mhtFilename: PAnsiChar): LongBool; cdecl;
  TCkMht_RemoveCustomHeader = procedure(handle: Pointer; name: PAnsiChar); cdecl;
  TCkMht_RestoreDefaults = procedure(handle: Pointer); cdecl;
  TCkMht_UnpackMHT = function(handle: Pointer; mhtFilename: PAnsiChar; unpackDir: PAnsiChar; htmlFilename: PAnsiChar; partsSubDir: PAnsiChar): LongBool; cdecl;
  TCkMht_UnpackMHTString = function(handle: Pointer; mhtString: PAnsiChar; unpackDir: PAnsiChar; htmlFilename: PAnsiChar; partsSubDir: PAnsiChar): LongBool; cdecl;

{ ---- C bridge function pointer variables ---- }
var
  CkMht_Create:  TCkMht_Create  = nil;
  CkMht_Dispose: TCkMht_Dispose = nil;
  CkMht_SetAbortCheckCallback:   TCkMht_SetAbortCheckCallback   = nil;
  CkMht_SetPercentDoneCallback:  TCkMht_SetPercentDoneCallback  = nil;
  CkMht_SetProgressInfoCallback: TCkMht_SetProgressInfoCallback = nil;
  CkMht_get_LastErrorHtml: TCkMht_get_LastErrorHtml = nil;
  CkMht_get_LastErrorText: TCkMht_get_LastErrorText = nil;
  CkMht_get_LastErrorXml: TCkMht_get_LastErrorXml = nil;
  CkMht_get_Version: TCkMht_get_Version = nil;
  CkMht_get_DebugLogFilePath: TCkMht_get_DebugLogFilePath = nil;
  CkMht_put_DebugLogFilePath: TCkMht_put_DebugLogFilePath = nil;
  CkMht_get_VerboseLogging: TCkMht_get_VerboseLogging = nil;
  CkMht_put_VerboseLogging: TCkMht_put_VerboseLogging = nil;
  CkMht_get_LastMethodSuccess: TCkMht_get_LastMethodSuccess = nil;
  CkMht_put_LastMethodSuccess: TCkMht_put_LastMethodSuccess = nil;
  CkMht_get_BaseUrl: TCkMht_get_BaseUrl = nil;
  CkMht_put_BaseUrl: TCkMht_put_BaseUrl = nil;
  CkMht_get_ConnectTimeout: TCkMht_get_ConnectTimeout = nil;
  CkMht_put_ConnectTimeout: TCkMht_put_ConnectTimeout = nil;
  CkMht_get_DebugHtmlAfter: TCkMht_get_DebugHtmlAfter = nil;
  CkMht_put_DebugHtmlAfter: TCkMht_put_DebugHtmlAfter = nil;
  CkMht_get_DebugHtmlBefore: TCkMht_get_DebugHtmlBefore = nil;
  CkMht_put_DebugHtmlBefore: TCkMht_put_DebugHtmlBefore = nil;
  CkMht_get_EmbedImages: TCkMht_get_EmbedImages = nil;
  CkMht_put_EmbedImages: TCkMht_put_EmbedImages = nil;
  CkMht_get_EmbedLocalOnly: TCkMht_get_EmbedLocalOnly = nil;
  CkMht_put_EmbedLocalOnly: TCkMht_put_EmbedLocalOnly = nil;
  CkMht_get_FetchFromCache: TCkMht_get_FetchFromCache = nil;
  CkMht_put_FetchFromCache: TCkMht_put_FetchFromCache = nil;
  CkMht_get_HeartbeatMs: TCkMht_get_HeartbeatMs = nil;
  CkMht_put_HeartbeatMs: TCkMht_put_HeartbeatMs = nil;
  CkMht_get_IgnoreMustRevalidate: TCkMht_get_IgnoreMustRevalidate = nil;
  CkMht_put_IgnoreMustRevalidate: TCkMht_put_IgnoreMustRevalidate = nil;
  CkMht_get_IgnoreNoCache: TCkMht_get_IgnoreNoCache = nil;
  CkMht_put_IgnoreNoCache: TCkMht_put_IgnoreNoCache = nil;
  CkMht_get_NoScripts: TCkMht_get_NoScripts = nil;
  CkMht_put_NoScripts: TCkMht_put_NoScripts = nil;
  CkMht_get_NtlmAuth: TCkMht_get_NtlmAuth = nil;
  CkMht_put_NtlmAuth: TCkMht_put_NtlmAuth = nil;
  CkMht_get_NumCacheLevels: TCkMht_get_NumCacheLevels = nil;
  CkMht_put_NumCacheLevels: TCkMht_put_NumCacheLevels = nil;
  CkMht_get_NumCacheRoots: TCkMht_get_NumCacheRoots = nil;
  CkMht_get_PreferIpv6: TCkMht_get_PreferIpv6 = nil;
  CkMht_put_PreferIpv6: TCkMht_put_PreferIpv6 = nil;
  CkMht_get_PreferMHTScripts: TCkMht_get_PreferMHTScripts = nil;
  CkMht_put_PreferMHTScripts: TCkMht_put_PreferMHTScripts = nil;
  CkMht_get_Proxy: TCkMht_get_Proxy = nil;
  CkMht_put_Proxy: TCkMht_put_Proxy = nil;
  CkMht_get_ProxyLogin: TCkMht_get_ProxyLogin = nil;
  CkMht_put_ProxyLogin: TCkMht_put_ProxyLogin = nil;
  CkMht_get_ProxyPassword: TCkMht_get_ProxyPassword = nil;
  CkMht_put_ProxyPassword: TCkMht_put_ProxyPassword = nil;
  CkMht_get_ReadTimeout: TCkMht_get_ReadTimeout = nil;
  CkMht_put_ReadTimeout: TCkMht_put_ReadTimeout = nil;
  CkMht_get_RequireSslCertVerify: TCkMht_get_RequireSslCertVerify = nil;
  CkMht_put_RequireSslCertVerify: TCkMht_put_RequireSslCertVerify = nil;
  CkMht_get_SocksHostname: TCkMht_get_SocksHostname = nil;
  CkMht_put_SocksHostname: TCkMht_put_SocksHostname = nil;
  CkMht_get_SocksPassword: TCkMht_get_SocksPassword = nil;
  CkMht_put_SocksPassword: TCkMht_put_SocksPassword = nil;
  CkMht_get_SocksPort: TCkMht_get_SocksPort = nil;
  CkMht_put_SocksPort: TCkMht_put_SocksPort = nil;
  CkMht_get_SocksUsername: TCkMht_get_SocksUsername = nil;
  CkMht_put_SocksUsername: TCkMht_put_SocksUsername = nil;
  CkMht_get_SocksVersion: TCkMht_get_SocksVersion = nil;
  CkMht_put_SocksVersion: TCkMht_put_SocksVersion = nil;
  CkMht_get_UnpackDirect: TCkMht_get_UnpackDirect = nil;
  CkMht_put_UnpackDirect: TCkMht_put_UnpackDirect = nil;
  CkMht_get_UnpackUseRelPaths: TCkMht_get_UnpackUseRelPaths = nil;
  CkMht_put_UnpackUseRelPaths: TCkMht_put_UnpackUseRelPaths = nil;
  CkMht_get_UpdateCache: TCkMht_get_UpdateCache = nil;
  CkMht_put_UpdateCache: TCkMht_put_UpdateCache = nil;
  CkMht_get_UseCids: TCkMht_get_UseCids = nil;
  CkMht_put_UseCids: TCkMht_put_UseCids = nil;
  CkMht_get_UseFilename: TCkMht_get_UseFilename = nil;
  CkMht_put_UseFilename: TCkMht_put_UseFilename = nil;
  CkMht_get_UseIEProxy: TCkMht_get_UseIEProxy = nil;
  CkMht_put_UseIEProxy: TCkMht_put_UseIEProxy = nil;
  CkMht_get_UseInline: TCkMht_get_UseInline = nil;
  CkMht_put_UseInline: TCkMht_put_UseInline = nil;
  CkMht_get_WebSiteLogin: TCkMht_get_WebSiteLogin = nil;
  CkMht_put_WebSiteLogin: TCkMht_put_WebSiteLogin = nil;
  CkMht_get_WebSiteLoginDomain: TCkMht_get_WebSiteLoginDomain = nil;
  CkMht_put_WebSiteLoginDomain: TCkMht_put_WebSiteLoginDomain = nil;
  CkMht_get_WebSitePassword: TCkMht_get_WebSitePassword = nil;
  CkMht_put_WebSitePassword: TCkMht_put_WebSitePassword = nil;
  CkMht_get_AbortCurrent: TCkMht_get_AbortCurrent = nil;
  CkMht_put_AbortCurrent: TCkMht_put_AbortCurrent = nil;
  CkMht_AddCacheRoot: TCkMht_AddCacheRoot = nil;
  CkMht_AddCustomHeader: TCkMht_AddCustomHeader = nil;
  CkMht_AddExternalStyleSheet: TCkMht_AddExternalStyleSheet = nil;
  CkMht_ClearCustomHeaders: TCkMht_ClearCustomHeaders = nil;
  CkMht_ExcludeImagesMatching: TCkMht_ExcludeImagesMatching = nil;
  CkMht_GetAndSaveEML: TCkMht_GetAndSaveEML = nil;
  CkMht_GetAndSaveMHT: TCkMht_GetAndSaveMHT = nil;
  CkMht_GetAndZipEML: TCkMht_GetAndZipEML = nil;
  CkMht_GetAndZipMHT: TCkMht_GetAndZipMHT = nil;
  CkMht_GetCacheRoot: TCkMht_GetCacheRoot = nil;
  CkMht_GetEML: TCkMht_GetEML = nil;
  CkMht_GetMHT: TCkMht_GetMHT = nil;
  CkMht_HtmlToEML: TCkMht_HtmlToEML = nil;
  CkMht_HtmlToEMLFile: TCkMht_HtmlToEMLFile = nil;
  CkMht_HtmlToMHT: TCkMht_HtmlToMHT = nil;
  CkMht_HtmlToMHTFile: TCkMht_HtmlToMHTFile = nil;
  CkMht_RemoveCustomHeader: TCkMht_RemoveCustomHeader = nil;
  CkMht_RestoreDefaults: TCkMht_RestoreDefaults = nil;
  CkMht_UnpackMHT: TCkMht_UnpackMHT = nil;
  CkMht_UnpackMHTString: TCkMht_UnpackMHTString = nil;

constructor TMht.Create;
begin
  inherited Create;
  FHandle := CkMht_Create();
end;

destructor TMht.Destroy;
begin
  if FHandle <> nil then
    CkMht_Dispose(FHandle);
  FHandle := nil;
  inherited;
end;

{ ---- Event callback thunks ---- }
{ Standalone cdecl functions registered with the C bridge.  The bridge
  passes back the userData pointer, which carries the Pascal object
  instance.  A non-zero return value aborts the running method. }

function TMht_AbortCheckThunk(userData: Pointer): Integer; cdecl;
var
  obj: TMht;
begin
  Result := 0;
  obj := TMht(userData);
  if Assigned(obj) and Assigned(obj.FOnAbortCheck) then
    if obj.FOnAbortCheck(obj) then Result := 1;
end;

function TMht_PercentDoneThunk(pctDone: Integer; userData: Pointer): Integer; cdecl;
var
  obj: TMht;
begin
  Result := 0;
  obj := TMht(userData);
  if Assigned(obj) and Assigned(obj.FOnPercentDone) then
    if obj.FOnPercentDone(obj, pctDone) then Result := 1;
end;

procedure TMht_ProgressInfoThunk(name: PAnsiChar; value: PAnsiChar; userData: Pointer); cdecl;
var
  obj: TMht;
begin
  obj := TMht(userData);
  if Assigned(obj) and Assigned(obj.FOnProgressInfo) then
    obj.FOnProgressInfo(obj, CkToStr(name), CkToStr(value));
end;

procedure TMht.SetOnAbortCheck(AValue: TChilkatAbortCheckEvent);
begin
  FOnAbortCheck := AValue;
  if Assigned(AValue) then
    CkMht_SetAbortCheckCallback(FHandle, @TMht_AbortCheckThunk, Self)
  else
    CkMht_SetAbortCheckCallback(FHandle, nil, nil);
end;

procedure TMht.SetOnPercentDone(AValue: TChilkatPercentDoneEvent);
begin
  FOnPercentDone := AValue;
  if Assigned(AValue) then
    CkMht_SetPercentDoneCallback(FHandle, @TMht_PercentDoneThunk, Self)
  else
    CkMht_SetPercentDoneCallback(FHandle, nil, nil);
end;

procedure TMht.SetOnProgressInfo(AValue: TChilkatProgressInfoEvent);
begin
  FOnProgressInfo := AValue;
  if Assigned(AValue) then
    CkMht_SetProgressInfoCallback(FHandle, @TMht_ProgressInfoThunk, Self)
  else
    CkMht_SetProgressInfoCallback(FHandle, nil, nil);
end;

function TMht.GetLastErrorHtml: string;
begin
  Result := CkToStr(CkMht_get_LastErrorHtml(FHandle));
end;

function TMht.GetLastErrorText: string;
begin
  Result := CkToStr(CkMht_get_LastErrorText(FHandle));
end;

function TMht.GetLastErrorXml: string;
begin
  Result := CkToStr(CkMht_get_LastErrorXml(FHandle));
end;

function TMht.GetVersion: string;
begin
  Result := CkToStr(CkMht_get_Version(FHandle));
end;

function TMht.GetDebugLogFilePath: string;
begin
  Result := CkToStr(CkMht_get_DebugLogFilePath(FHandle));
end;

procedure TMht.SetDebugLogFilePath(AValue: string);
begin
  CkMht_put_DebugLogFilePath(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TMht.GetVerboseLogging: Boolean;
begin
  Result := Boolean(CkMht_get_VerboseLogging(FHandle));
end;

procedure TMht.SetVerboseLogging(AValue: Boolean);
begin
  CkMht_put_VerboseLogging(FHandle, LongBool(AValue));
end;

function TMht.GetLastMethodSuccess: Boolean;
begin
  Result := Boolean(CkMht_get_LastMethodSuccess(FHandle));
end;

procedure TMht.SetLastMethodSuccess(AValue: Boolean);
begin
  CkMht_put_LastMethodSuccess(FHandle, LongBool(AValue));
end;

function TMht.GetBaseUrl: string;
begin
  Result := CkToStr(CkMht_get_BaseUrl(FHandle));
end;

procedure TMht.SetBaseUrl(AValue: string);
begin
  CkMht_put_BaseUrl(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TMht.GetConnectTimeout: Integer;
begin
  Result := CkMht_get_ConnectTimeout(FHandle);
end;

procedure TMht.SetConnectTimeout(AValue: Integer);
begin
  CkMht_put_ConnectTimeout(FHandle, AValue);
end;

function TMht.GetDebugHtmlAfter: string;
begin
  Result := CkToStr(CkMht_get_DebugHtmlAfter(FHandle));
end;

procedure TMht.SetDebugHtmlAfter(AValue: string);
begin
  CkMht_put_DebugHtmlAfter(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TMht.GetDebugHtmlBefore: string;
begin
  Result := CkToStr(CkMht_get_DebugHtmlBefore(FHandle));
end;

procedure TMht.SetDebugHtmlBefore(AValue: string);
begin
  CkMht_put_DebugHtmlBefore(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TMht.GetEmbedImages: Boolean;
begin
  Result := Boolean(CkMht_get_EmbedImages(FHandle));
end;

procedure TMht.SetEmbedImages(AValue: Boolean);
begin
  CkMht_put_EmbedImages(FHandle, LongBool(AValue));
end;

function TMht.GetEmbedLocalOnly: Boolean;
begin
  Result := Boolean(CkMht_get_EmbedLocalOnly(FHandle));
end;

procedure TMht.SetEmbedLocalOnly(AValue: Boolean);
begin
  CkMht_put_EmbedLocalOnly(FHandle, LongBool(AValue));
end;

function TMht.GetFetchFromCache: Boolean;
begin
  Result := Boolean(CkMht_get_FetchFromCache(FHandle));
end;

procedure TMht.SetFetchFromCache(AValue: Boolean);
begin
  CkMht_put_FetchFromCache(FHandle, LongBool(AValue));
end;

function TMht.GetHeartbeatMs: Integer;
begin
  Result := CkMht_get_HeartbeatMs(FHandle);
end;

procedure TMht.SetHeartbeatMs(AValue: Integer);
begin
  CkMht_put_HeartbeatMs(FHandle, AValue);
end;

function TMht.GetIgnoreMustRevalidate: Boolean;
begin
  Result := Boolean(CkMht_get_IgnoreMustRevalidate(FHandle));
end;

procedure TMht.SetIgnoreMustRevalidate(AValue: Boolean);
begin
  CkMht_put_IgnoreMustRevalidate(FHandle, LongBool(AValue));
end;

function TMht.GetIgnoreNoCache: Boolean;
begin
  Result := Boolean(CkMht_get_IgnoreNoCache(FHandle));
end;

procedure TMht.SetIgnoreNoCache(AValue: Boolean);
begin
  CkMht_put_IgnoreNoCache(FHandle, LongBool(AValue));
end;

function TMht.GetNoScripts: Boolean;
begin
  Result := Boolean(CkMht_get_NoScripts(FHandle));
end;

procedure TMht.SetNoScripts(AValue: Boolean);
begin
  CkMht_put_NoScripts(FHandle, LongBool(AValue));
end;

function TMht.GetNtlmAuth: Boolean;
begin
  Result := Boolean(CkMht_get_NtlmAuth(FHandle));
end;

procedure TMht.SetNtlmAuth(AValue: Boolean);
begin
  CkMht_put_NtlmAuth(FHandle, LongBool(AValue));
end;

function TMht.GetNumCacheLevels: Integer;
begin
  Result := CkMht_get_NumCacheLevels(FHandle);
end;

procedure TMht.SetNumCacheLevels(AValue: Integer);
begin
  CkMht_put_NumCacheLevels(FHandle, AValue);
end;

function TMht.GetNumCacheRoots: Integer;
begin
  Result := CkMht_get_NumCacheRoots(FHandle);
end;

function TMht.GetPreferIpv6: Boolean;
begin
  Result := Boolean(CkMht_get_PreferIpv6(FHandle));
end;

procedure TMht.SetPreferIpv6(AValue: Boolean);
begin
  CkMht_put_PreferIpv6(FHandle, LongBool(AValue));
end;

function TMht.GetPreferMHTScripts: Boolean;
begin
  Result := Boolean(CkMht_get_PreferMHTScripts(FHandle));
end;

procedure TMht.SetPreferMHTScripts(AValue: Boolean);
begin
  CkMht_put_PreferMHTScripts(FHandle, LongBool(AValue));
end;

function TMht.GetProxy: string;
begin
  Result := CkToStr(CkMht_get_Proxy(FHandle));
end;

procedure TMht.SetProxy(AValue: string);
begin
  CkMht_put_Proxy(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TMht.GetProxyLogin: string;
begin
  Result := CkToStr(CkMht_get_ProxyLogin(FHandle));
end;

procedure TMht.SetProxyLogin(AValue: string);
begin
  CkMht_put_ProxyLogin(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TMht.GetProxyPassword: string;
begin
  Result := CkToStr(CkMht_get_ProxyPassword(FHandle));
end;

procedure TMht.SetProxyPassword(AValue: string);
begin
  CkMht_put_ProxyPassword(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TMht.GetReadTimeout: Integer;
begin
  Result := CkMht_get_ReadTimeout(FHandle);
end;

procedure TMht.SetReadTimeout(AValue: Integer);
begin
  CkMht_put_ReadTimeout(FHandle, AValue);
end;

function TMht.GetRequireSslCertVerify: Boolean;
begin
  Result := Boolean(CkMht_get_RequireSslCertVerify(FHandle));
end;

procedure TMht.SetRequireSslCertVerify(AValue: Boolean);
begin
  CkMht_put_RequireSslCertVerify(FHandle, LongBool(AValue));
end;

function TMht.GetSocksHostname: string;
begin
  Result := CkToStr(CkMht_get_SocksHostname(FHandle));
end;

procedure TMht.SetSocksHostname(AValue: string);
begin
  CkMht_put_SocksHostname(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TMht.GetSocksPassword: string;
begin
  Result := CkToStr(CkMht_get_SocksPassword(FHandle));
end;

procedure TMht.SetSocksPassword(AValue: string);
begin
  CkMht_put_SocksPassword(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TMht.GetSocksPort: Integer;
begin
  Result := CkMht_get_SocksPort(FHandle);
end;

procedure TMht.SetSocksPort(AValue: Integer);
begin
  CkMht_put_SocksPort(FHandle, AValue);
end;

function TMht.GetSocksUsername: string;
begin
  Result := CkToStr(CkMht_get_SocksUsername(FHandle));
end;

procedure TMht.SetSocksUsername(AValue: string);
begin
  CkMht_put_SocksUsername(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TMht.GetSocksVersion: Integer;
begin
  Result := CkMht_get_SocksVersion(FHandle);
end;

procedure TMht.SetSocksVersion(AValue: Integer);
begin
  CkMht_put_SocksVersion(FHandle, AValue);
end;

function TMht.GetUnpackDirect: Boolean;
begin
  Result := Boolean(CkMht_get_UnpackDirect(FHandle));
end;

procedure TMht.SetUnpackDirect(AValue: Boolean);
begin
  CkMht_put_UnpackDirect(FHandle, LongBool(AValue));
end;

function TMht.GetUnpackUseRelPaths: Boolean;
begin
  Result := Boolean(CkMht_get_UnpackUseRelPaths(FHandle));
end;

procedure TMht.SetUnpackUseRelPaths(AValue: Boolean);
begin
  CkMht_put_UnpackUseRelPaths(FHandle, LongBool(AValue));
end;

function TMht.GetUpdateCache: Boolean;
begin
  Result := Boolean(CkMht_get_UpdateCache(FHandle));
end;

procedure TMht.SetUpdateCache(AValue: Boolean);
begin
  CkMht_put_UpdateCache(FHandle, LongBool(AValue));
end;

function TMht.GetUseCids: Boolean;
begin
  Result := Boolean(CkMht_get_UseCids(FHandle));
end;

procedure TMht.SetUseCids(AValue: Boolean);
begin
  CkMht_put_UseCids(FHandle, LongBool(AValue));
end;

function TMht.GetUseFilename: Boolean;
begin
  Result := Boolean(CkMht_get_UseFilename(FHandle));
end;

procedure TMht.SetUseFilename(AValue: Boolean);
begin
  CkMht_put_UseFilename(FHandle, LongBool(AValue));
end;

function TMht.GetUseIEProxy: Boolean;
begin
  Result := Boolean(CkMht_get_UseIEProxy(FHandle));
end;

procedure TMht.SetUseIEProxy(AValue: Boolean);
begin
  CkMht_put_UseIEProxy(FHandle, LongBool(AValue));
end;

function TMht.GetUseInline: Boolean;
begin
  Result := Boolean(CkMht_get_UseInline(FHandle));
end;

procedure TMht.SetUseInline(AValue: Boolean);
begin
  CkMht_put_UseInline(FHandle, LongBool(AValue));
end;

function TMht.GetWebSiteLogin: string;
begin
  Result := CkToStr(CkMht_get_WebSiteLogin(FHandle));
end;

procedure TMht.SetWebSiteLogin(AValue: string);
begin
  CkMht_put_WebSiteLogin(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TMht.GetWebSiteLoginDomain: string;
begin
  Result := CkToStr(CkMht_get_WebSiteLoginDomain(FHandle));
end;

procedure TMht.SetWebSiteLoginDomain(AValue: string);
begin
  CkMht_put_WebSiteLoginDomain(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TMht.GetWebSitePassword: string;
begin
  Result := CkToStr(CkMht_get_WebSitePassword(FHandle));
end;

procedure TMht.SetWebSitePassword(AValue: string);
begin
  CkMht_put_WebSitePassword(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TMht.GetAbortCurrent: Boolean;
begin
  Result := Boolean(CkMht_get_AbortCurrent(FHandle));
end;

procedure TMht.SetAbortCurrent(AValue: Boolean);
begin
  CkMht_put_AbortCurrent(FHandle, LongBool(AValue));
end;

procedure TMht.AddCacheRoot(const dir: string);
begin
  CkMht_AddCacheRoot(FHandle, PAnsiChar(StrToCk(dir)));
end;

procedure TMht.AddCustomHeader(const name: string; const value: string);
begin
  CkMht_AddCustomHeader(FHandle, PAnsiChar(StrToCk(name)), PAnsiChar(StrToCk(value)));
end;

procedure TMht.AddExternalStyleSheet(const url: string);
begin
  CkMht_AddExternalStyleSheet(FHandle, PAnsiChar(StrToCk(url)));
end;

procedure TMht.ClearCustomHeaders;
begin
  CkMht_ClearCustomHeaders(FHandle);
end;

procedure TMht.ExcludeImagesMatching(const pattern: string);
begin
  CkMht_ExcludeImagesMatching(FHandle, PAnsiChar(StrToCk(pattern)));
end;

function TMht.GetAndSaveEML(const url_or_htmlFilepath: string; const emlPath: string): Boolean;
begin
  Result := Boolean(CkMht_GetAndSaveEML(FHandle, PAnsiChar(StrToCk(url_or_htmlFilepath)), PAnsiChar(StrToCk(emlPath))));
end;

function TMht.GetAndSaveMHT(const url_or_htmlFilepath: string; const mhtPath: string): Boolean;
begin
  Result := Boolean(CkMht_GetAndSaveMHT(FHandle, PAnsiChar(StrToCk(url_or_htmlFilepath)), PAnsiChar(StrToCk(mhtPath))));
end;

function TMht.GetAndZipEML(const url_or_htmlFilepath: string; const zipEntryFilename: string; const zipFilename: string): Boolean;
begin
  Result := Boolean(CkMht_GetAndZipEML(FHandle, PAnsiChar(StrToCk(url_or_htmlFilepath)), PAnsiChar(StrToCk(zipEntryFilename)), PAnsiChar(StrToCk(zipFilename))));
end;

function TMht.GetAndZipMHT(const url_or_htmlFilepath: string; const zipEntryFilename: string; const zipFilename: string): Boolean;
begin
  Result := Boolean(CkMht_GetAndZipMHT(FHandle, PAnsiChar(StrToCk(url_or_htmlFilepath)), PAnsiChar(StrToCk(zipEntryFilename)), PAnsiChar(StrToCk(zipFilename))));
end;

function TMht.GetCacheRoot(index: Integer): string;
begin
  Result := CkToStr(CkMht_GetCacheRoot(FHandle, index));
end;

function TMht.GetEML(const url_or_htmlFilepath: string): string;
begin
  Result := CkToStr(CkMht_GetEML(FHandle, PAnsiChar(StrToCk(url_or_htmlFilepath))));
end;

function TMht.GetMHT(const url_or_htmlFilepath: string): string;
begin
  Result := CkToStr(CkMht_GetMHT(FHandle, PAnsiChar(StrToCk(url_or_htmlFilepath))));
end;

function TMht.HtmlToEML(const htmlText: string): string;
begin
  Result := CkToStr(CkMht_HtmlToEML(FHandle, PAnsiChar(StrToCk(htmlText))));
end;

function TMht.HtmlToEMLFile(const html: string; const emlFilename: string): Boolean;
begin
  Result := Boolean(CkMht_HtmlToEMLFile(FHandle, PAnsiChar(StrToCk(html)), PAnsiChar(StrToCk(emlFilename))));
end;

function TMht.HtmlToMHT(const htmlText: string): string;
begin
  Result := CkToStr(CkMht_HtmlToMHT(FHandle, PAnsiChar(StrToCk(htmlText))));
end;

function TMht.HtmlToMHTFile(const html: string; const mhtFilename: string): Boolean;
begin
  Result := Boolean(CkMht_HtmlToMHTFile(FHandle, PAnsiChar(StrToCk(html)), PAnsiChar(StrToCk(mhtFilename))));
end;

procedure TMht.RemoveCustomHeader(const name: string);
begin
  CkMht_RemoveCustomHeader(FHandle, PAnsiChar(StrToCk(name)));
end;

procedure TMht.RestoreDefaults;
begin
  CkMht_RestoreDefaults(FHandle);
end;

function TMht.UnpackMHT(const mhtFilename: string; const unpackDir: string; const htmlFilename: string; const partsSubDir: string): Boolean;
begin
  Result := Boolean(CkMht_UnpackMHT(FHandle, PAnsiChar(StrToCk(mhtFilename)), PAnsiChar(StrToCk(unpackDir)), PAnsiChar(StrToCk(htmlFilename)), PAnsiChar(StrToCk(partsSubDir))));
end;

function TMht.UnpackMHTString(const mhtString: string; const unpackDir: string; const htmlFilename: string; const partsSubDir: string): Boolean;
begin
  Result := Boolean(CkMht_UnpackMHTString(FHandle, PAnsiChar(StrToCk(mhtString)), PAnsiChar(StrToCk(unpackDir)), PAnsiChar(StrToCk(htmlFilename)), PAnsiChar(StrToCk(partsSubDir))));
end;

initialization
  Chilkat_GetProcedureAddress(CkMht_Create,  'CkMht_Create');
  Chilkat_GetProcedureAddress(CkMht_Dispose, 'CkMht_Dispose');
  Chilkat_GetProcedureAddress(CkMht_SetAbortCheckCallback, 'CkMht_SetAbortCheckCallback');
  Chilkat_GetProcedureAddress(CkMht_SetPercentDoneCallback, 'CkMht_SetPercentDoneCallback');
  Chilkat_GetProcedureAddress(CkMht_SetProgressInfoCallback, 'CkMht_SetProgressInfoCallback');
  Chilkat_GetProcedureAddress(CkMht_get_LastErrorHtml, 'CkMht_get_LastErrorHtml');
  Chilkat_GetProcedureAddress(CkMht_get_LastErrorText, 'CkMht_get_LastErrorText');
  Chilkat_GetProcedureAddress(CkMht_get_LastErrorXml, 'CkMht_get_LastErrorXml');
  Chilkat_GetProcedureAddress(CkMht_get_Version, 'CkMht_get_Version');
  Chilkat_GetProcedureAddress(CkMht_get_DebugLogFilePath, 'CkMht_get_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkMht_put_DebugLogFilePath, 'CkMht_put_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkMht_get_VerboseLogging, 'CkMht_get_VerboseLogging');
  Chilkat_GetProcedureAddress(CkMht_put_VerboseLogging, 'CkMht_put_VerboseLogging');
  Chilkat_GetProcedureAddress(CkMht_get_LastMethodSuccess, 'CkMht_get_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkMht_put_LastMethodSuccess, 'CkMht_put_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkMht_get_BaseUrl, 'CkMht_get_BaseUrl');
  Chilkat_GetProcedureAddress(CkMht_put_BaseUrl, 'CkMht_put_BaseUrl');
  Chilkat_GetProcedureAddress(CkMht_get_ConnectTimeout, 'CkMht_get_ConnectTimeout');
  Chilkat_GetProcedureAddress(CkMht_put_ConnectTimeout, 'CkMht_put_ConnectTimeout');
  Chilkat_GetProcedureAddress(CkMht_get_DebugHtmlAfter, 'CkMht_get_DebugHtmlAfter');
  Chilkat_GetProcedureAddress(CkMht_put_DebugHtmlAfter, 'CkMht_put_DebugHtmlAfter');
  Chilkat_GetProcedureAddress(CkMht_get_DebugHtmlBefore, 'CkMht_get_DebugHtmlBefore');
  Chilkat_GetProcedureAddress(CkMht_put_DebugHtmlBefore, 'CkMht_put_DebugHtmlBefore');
  Chilkat_GetProcedureAddress(CkMht_get_EmbedImages, 'CkMht_get_EmbedImages');
  Chilkat_GetProcedureAddress(CkMht_put_EmbedImages, 'CkMht_put_EmbedImages');
  Chilkat_GetProcedureAddress(CkMht_get_EmbedLocalOnly, 'CkMht_get_EmbedLocalOnly');
  Chilkat_GetProcedureAddress(CkMht_put_EmbedLocalOnly, 'CkMht_put_EmbedLocalOnly');
  Chilkat_GetProcedureAddress(CkMht_get_FetchFromCache, 'CkMht_get_FetchFromCache');
  Chilkat_GetProcedureAddress(CkMht_put_FetchFromCache, 'CkMht_put_FetchFromCache');
  Chilkat_GetProcedureAddress(CkMht_get_HeartbeatMs, 'CkMht_get_HeartbeatMs');
  Chilkat_GetProcedureAddress(CkMht_put_HeartbeatMs, 'CkMht_put_HeartbeatMs');
  Chilkat_GetProcedureAddress(CkMht_get_IgnoreMustRevalidate, 'CkMht_get_IgnoreMustRevalidate');
  Chilkat_GetProcedureAddress(CkMht_put_IgnoreMustRevalidate, 'CkMht_put_IgnoreMustRevalidate');
  Chilkat_GetProcedureAddress(CkMht_get_IgnoreNoCache, 'CkMht_get_IgnoreNoCache');
  Chilkat_GetProcedureAddress(CkMht_put_IgnoreNoCache, 'CkMht_put_IgnoreNoCache');
  Chilkat_GetProcedureAddress(CkMht_get_NoScripts, 'CkMht_get_NoScripts');
  Chilkat_GetProcedureAddress(CkMht_put_NoScripts, 'CkMht_put_NoScripts');
  Chilkat_GetProcedureAddress(CkMht_get_NtlmAuth, 'CkMht_get_NtlmAuth');
  Chilkat_GetProcedureAddress(CkMht_put_NtlmAuth, 'CkMht_put_NtlmAuth');
  Chilkat_GetProcedureAddress(CkMht_get_NumCacheLevels, 'CkMht_get_NumCacheLevels');
  Chilkat_GetProcedureAddress(CkMht_put_NumCacheLevels, 'CkMht_put_NumCacheLevels');
  Chilkat_GetProcedureAddress(CkMht_get_NumCacheRoots, 'CkMht_get_NumCacheRoots');
  Chilkat_GetProcedureAddress(CkMht_get_PreferIpv6, 'CkMht_get_PreferIpv6');
  Chilkat_GetProcedureAddress(CkMht_put_PreferIpv6, 'CkMht_put_PreferIpv6');
  Chilkat_GetProcedureAddress(CkMht_get_PreferMHTScripts, 'CkMht_get_PreferMHTScripts');
  Chilkat_GetProcedureAddress(CkMht_put_PreferMHTScripts, 'CkMht_put_PreferMHTScripts');
  Chilkat_GetProcedureAddress(CkMht_get_Proxy, 'CkMht_get_Proxy');
  Chilkat_GetProcedureAddress(CkMht_put_Proxy, 'CkMht_put_Proxy');
  Chilkat_GetProcedureAddress(CkMht_get_ProxyLogin, 'CkMht_get_ProxyLogin');
  Chilkat_GetProcedureAddress(CkMht_put_ProxyLogin, 'CkMht_put_ProxyLogin');
  Chilkat_GetProcedureAddress(CkMht_get_ProxyPassword, 'CkMht_get_ProxyPassword');
  Chilkat_GetProcedureAddress(CkMht_put_ProxyPassword, 'CkMht_put_ProxyPassword');
  Chilkat_GetProcedureAddress(CkMht_get_ReadTimeout, 'CkMht_get_ReadTimeout');
  Chilkat_GetProcedureAddress(CkMht_put_ReadTimeout, 'CkMht_put_ReadTimeout');
  Chilkat_GetProcedureAddress(CkMht_get_RequireSslCertVerify, 'CkMht_get_RequireSslCertVerify');
  Chilkat_GetProcedureAddress(CkMht_put_RequireSslCertVerify, 'CkMht_put_RequireSslCertVerify');
  Chilkat_GetProcedureAddress(CkMht_get_SocksHostname, 'CkMht_get_SocksHostname');
  Chilkat_GetProcedureAddress(CkMht_put_SocksHostname, 'CkMht_put_SocksHostname');
  Chilkat_GetProcedureAddress(CkMht_get_SocksPassword, 'CkMht_get_SocksPassword');
  Chilkat_GetProcedureAddress(CkMht_put_SocksPassword, 'CkMht_put_SocksPassword');
  Chilkat_GetProcedureAddress(CkMht_get_SocksPort, 'CkMht_get_SocksPort');
  Chilkat_GetProcedureAddress(CkMht_put_SocksPort, 'CkMht_put_SocksPort');
  Chilkat_GetProcedureAddress(CkMht_get_SocksUsername, 'CkMht_get_SocksUsername');
  Chilkat_GetProcedureAddress(CkMht_put_SocksUsername, 'CkMht_put_SocksUsername');
  Chilkat_GetProcedureAddress(CkMht_get_SocksVersion, 'CkMht_get_SocksVersion');
  Chilkat_GetProcedureAddress(CkMht_put_SocksVersion, 'CkMht_put_SocksVersion');
  Chilkat_GetProcedureAddress(CkMht_get_UnpackDirect, 'CkMht_get_UnpackDirect');
  Chilkat_GetProcedureAddress(CkMht_put_UnpackDirect, 'CkMht_put_UnpackDirect');
  Chilkat_GetProcedureAddress(CkMht_get_UnpackUseRelPaths, 'CkMht_get_UnpackUseRelPaths');
  Chilkat_GetProcedureAddress(CkMht_put_UnpackUseRelPaths, 'CkMht_put_UnpackUseRelPaths');
  Chilkat_GetProcedureAddress(CkMht_get_UpdateCache, 'CkMht_get_UpdateCache');
  Chilkat_GetProcedureAddress(CkMht_put_UpdateCache, 'CkMht_put_UpdateCache');
  Chilkat_GetProcedureAddress(CkMht_get_UseCids, 'CkMht_get_UseCids');
  Chilkat_GetProcedureAddress(CkMht_put_UseCids, 'CkMht_put_UseCids');
  Chilkat_GetProcedureAddress(CkMht_get_UseFilename, 'CkMht_get_UseFilename');
  Chilkat_GetProcedureAddress(CkMht_put_UseFilename, 'CkMht_put_UseFilename');
  Chilkat_GetProcedureAddress(CkMht_get_UseIEProxy, 'CkMht_get_UseIEProxy');
  Chilkat_GetProcedureAddress(CkMht_put_UseIEProxy, 'CkMht_put_UseIEProxy');
  Chilkat_GetProcedureAddress(CkMht_get_UseInline, 'CkMht_get_UseInline');
  Chilkat_GetProcedureAddress(CkMht_put_UseInline, 'CkMht_put_UseInline');
  Chilkat_GetProcedureAddress(CkMht_get_WebSiteLogin, 'CkMht_get_WebSiteLogin');
  Chilkat_GetProcedureAddress(CkMht_put_WebSiteLogin, 'CkMht_put_WebSiteLogin');
  Chilkat_GetProcedureAddress(CkMht_get_WebSiteLoginDomain, 'CkMht_get_WebSiteLoginDomain');
  Chilkat_GetProcedureAddress(CkMht_put_WebSiteLoginDomain, 'CkMht_put_WebSiteLoginDomain');
  Chilkat_GetProcedureAddress(CkMht_get_WebSitePassword, 'CkMht_get_WebSitePassword');
  Chilkat_GetProcedureAddress(CkMht_put_WebSitePassword, 'CkMht_put_WebSitePassword');
  Chilkat_GetProcedureAddress(CkMht_get_AbortCurrent, 'CkMht_get_AbortCurrent');
  Chilkat_GetProcedureAddress(CkMht_put_AbortCurrent, 'CkMht_put_AbortCurrent');
  Chilkat_GetProcedureAddress(CkMht_AddCacheRoot, 'CkMht_AddCacheRoot');
  Chilkat_GetProcedureAddress(CkMht_AddCustomHeader, 'CkMht_AddCustomHeader');
  Chilkat_GetProcedureAddress(CkMht_AddExternalStyleSheet, 'CkMht_AddExternalStyleSheet');
  Chilkat_GetProcedureAddress(CkMht_ClearCustomHeaders, 'CkMht_ClearCustomHeaders');
  Chilkat_GetProcedureAddress(CkMht_ExcludeImagesMatching, 'CkMht_ExcludeImagesMatching');
  Chilkat_GetProcedureAddress(CkMht_GetAndSaveEML, 'CkMht_GetAndSaveEML');
  Chilkat_GetProcedureAddress(CkMht_GetAndSaveMHT, 'CkMht_GetAndSaveMHT');
  Chilkat_GetProcedureAddress(CkMht_GetAndZipEML, 'CkMht_GetAndZipEML');
  Chilkat_GetProcedureAddress(CkMht_GetAndZipMHT, 'CkMht_GetAndZipMHT');
  Chilkat_GetProcedureAddress(CkMht_GetCacheRoot, 'CkMht_GetCacheRoot');
  Chilkat_GetProcedureAddress(CkMht_GetEML, 'CkMht_GetEML');
  Chilkat_GetProcedureAddress(CkMht_GetMHT, 'CkMht_GetMHT');
  Chilkat_GetProcedureAddress(CkMht_HtmlToEML, 'CkMht_HtmlToEML');
  Chilkat_GetProcedureAddress(CkMht_HtmlToEMLFile, 'CkMht_HtmlToEMLFile');
  Chilkat_GetProcedureAddress(CkMht_HtmlToMHT, 'CkMht_HtmlToMHT');
  Chilkat_GetProcedureAddress(CkMht_HtmlToMHTFile, 'CkMht_HtmlToMHTFile');
  Chilkat_GetProcedureAddress(CkMht_RemoveCustomHeader, 'CkMht_RemoveCustomHeader');
  Chilkat_GetProcedureAddress(CkMht_RestoreDefaults, 'CkMht_RestoreDefaults');
  Chilkat_GetProcedureAddress(CkMht_UnpackMHT, 'CkMht_UnpackMHT');
  Chilkat_GetProcedureAddress(CkMht_UnpackMHTString, 'CkMht_UnpackMHTString');

end.
