tryraiseexc_dll.dpr

来自「delphi开发语言下的源代码分析」· DPR 代码 · 共 43 行

DPR
43
字号
library TryRaiseExc_DLL;

uses
  SysUtils;

type
  TTryException = class(Exception)
  private
    FMsgID : Integer;
  public
    constructor Create (const Msg: string);
    property MsgID: Integer read FMsgID;
  end;


// code from IniFiles.pas, TStringHash.HashOf()
function Encode(const S: string) : Integer;
var
  I: Integer;
begin
  Result := 0;
  for I := 1 to Length(S) do
    Result := ((Result shl 2) or (Result shr (SizeOf(Result) * 8 - 2))) xor
      Ord(S[I]);
end;

constructor TTryException.Create (const Msg: string);
begin
  inherited;
  FMsgID := Encode(Msg);
end;

procedure DoSomething;
begin
  raise TTryException.Create('Exception In DLL.');
end;

exports
  DoSomething;

begin
end.

⌨️ 快捷键说明

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