1

我必须使用运行时类型信息构建我的程序,因此检查编译器选项Emit runtime type information
但是有了这个设置,LockBox3 单元uTPLb_codecIntf.pas给出了错误E2134 类型在包含实现的行上没有类型信息(参见源代码的底部)。

LockBox3\run\源)文件夹位于我的库路径中(由安装指定)。
LockBox DCU 的d:\LockBox3\packages\Sydney\Delphi\Win32\Release\日期自安装之日起。

我怎样才能摆脱错误消息但 RTTI 可用?

编辑FWIW,这些是以下内容uTPLb_codecIntf.pas

interface
uses SysUtils, Classes, uTPLb_StreamCipher, uTPLb_BlockCipher,
     uTPLb_CryptographicLibrary;

type
TCodecMode = (cmUnitialized, cmIdle, cmEncrypting, cmDecrypting);

TOnEncDecProgress = function ( Sender: TObject; CountBytesProcessed: int64): boolean of object;

TGenerateAsymetricKeyPairProgress = procedure (
  Sender: TObject; CountPrimalityTests: integer;
  var doAbort: boolean) of object;


ICodec = interface
  ['{48B3116A-5681-4E79-9013-8EC89BAC5B35}']
    procedure SetStreamCipher( const Value: IStreamCipher);
    procedure SetBlockCipher ( const Value: IBlockCipher);
    procedure SetChainMode   ( const Value: IBlockChainingModel);
    function  GetMode: TCodecMode;
    function  GetStreamCipher: IStreamCipher;
    function  GetBlockCipher : IBlockCipher;
    function  GetChainMode   : IBlockChainingModel;
    function  GetOnProgress  : TOnEncDecProgress;
    procedure SetOnProgress( Value: TOnEncDecProgress);
    function  GetAsymetricKeySizeInBits: cardinal;
    procedure SetAsymetricKeySizeInBits( value: cardinal);
    function  GetAsymGenProgressEvent: TGenerateAsymetricKeyPairProgress;
    procedure SetAsymGenProgressEvent( Value: TGenerateAsymetricKeyPairProgress);
    function  GetKey: TSymetricKey;

    function  GetCipherDisplayName( Lib: TCryptographicLibrary): string;

    procedure Init(const Key: string; AEncoding: TEncoding);
    procedure SaveKeyToStream( Store: TStream);
    procedure InitFromStream( Store: TStream);
    procedure InitFromKey( Key: TSymetricKey);   // Transfers ownership.
    procedure Reset;
    procedure Burn( doIncludeBurnKey: boolean);

    // Asymetric support
    function  isAsymetric: boolean;
    procedure InitFromGeneratedAsymetricKeyPair;

    procedure Sign(
      Document, Signature: TStream;
      ProgressSender: TObject;
      ProgressEvent: TOnEncDecProgress;
      SigningKeys_PrivatePart: TObject;  // Must be uTPLb_Asymetric.TAsymtricKeyPart
      var wasAborted: boolean);

    function VerifySignature(
      Document, Signature: TStream;
      ProgressSender: TObject;
      ProgressEvent: TOnEncDecProgress;
      SigningKeys_PublicPart: TObject; // Must be uTPLb_Asymetric.TAsymtricKeyPart
      var wasAborted: boolean): boolean;


    procedure Begin_EncryptMemory( CipherText{out}: TStream);
    procedure EncryptMemory(const Plaintext: TBytes; PlaintextLen: Integer);
    procedure End_EncryptMemory;

    procedure Begin_DecryptMemory( PlainText{out}: TStream);
    procedure DecryptMemory( const CipherText{in}; CiphertextLen: integer);
    procedure End_DecryptMemory;

    procedure EncryptStream( Plaintext, CipherText: TStream);
    procedure DecryptStream( Plaintext, CipherText: TStream);

    procedure EncryptFile( const Plaintext_FileName, CipherText_FileName: string);
    procedure DecryptFile( const Plaintext_FileName, CipherText_FileName: string);

    procedure EncryptString(const Plaintext: string; var CipherText_Base64: string; AEncoding: TEncoding);
    procedure DecryptString(var Plaintext: string; const CipherText_Base64: string; AEncoding: TEncoding);

    procedure EncryptAnsiString(const Plaintext: string; var CipherText_Base64: string);
    procedure DecryptAnsiString(var Plaintext: string; const CipherText_Base64: string);

    function  GetAborted: boolean;
    procedure SetAborted( Value: boolean);
    function  GetAdvancedOptions2 : TSymetricEncryptionOptionSet;
    procedure SetAdvancedOptions2( Value: TSymetricEncryptionOptionSet);
    function  GetOnSetIV: TSetMemStreamProc;
    procedure SetOnSetIV( Value: TSetMemStreamProc);

    property  Mode: TCodecMode                   read GetMode;
    property  Key: TSymetricKey                  read GetKey;
    property  StreamCipher: IStreamCipher        read GetStreamCipher write SetStreamCipher;
    property  BlockCipher : IBlockCipher         read GetBlockCipher  write SetBlockCipher;
    property  ChainMode   : IBlockChainingModel  read GetChainMode    write SetChainMode;
    property  OnProgress  : TOnEncDecProgress    read GetonProgress   write SetOnProgress;
    property  AsymetricKeySizeInBits: cardinal   read GetAsymetricKeySizeInBits
                                                 write SetAsymetricKeySizeInBits;
    property  OnAsymGenProgress: TGenerateAsymetricKeyPairProgress
                                           read GetAsymGenProgressEvent write SetAsymGenProgressEvent;
    property isUserAborted: boolean              read GetAborted write SetAborted;
  end;


implementation

end.
4

2 回答 2

2

LockBox 作者建议将源文件夹放在您的库路径中的事实并不意味着您必须这样做。跟踪他们的代码很方便,但不是必需的。

只需从该列表中删除它们并将 .dcu 目录添加d:\LockBox3\packages\Sydney\Delphi\Win32\Release\到其中即可。

这使错误消失,我不需要在 LockBox 源中使用 RTTI。

于 2021-01-03T13:28:39.190 回答
1

您需要使用运行时信息重建 dcus。执行此操作的最简单方法(也仅包括此项目中的 dcu,而不是所有项目)是在您的项目中包含源文件 uTPLb_codecIntf.pas 并构建项目。根据您需要的 RTTI,您可能需要对其他源文件重复该过程。

于 2021-01-03T16:18:44.307 回答