質問

I'm trying to implement a record pointer in Inno Setup (Unicode) to match a Delphi DLL's specifications...

type
  PUnzipFile = ^TUnzipFile;
  TUnzipFile = record
    Caption: WideString;
    Src: WideString;
    Dest: WideString;
    Status: Integer;
    Size: Integer;
    ErrCode: Integer;
    ErrMsg: WideString;
  end;
  TUnzipFiles = array of PUnzipFile;

function UnzipFiles(var Files: TUnzipFiles; const Silent: Bool): Bool;
  external 'UnzipFiles@files:Unzipper.dll stdcall';

The problem is that the compiler fails on the line PUnzipFile = ^TUnzipFile; because apparently Inno Setup doesn't support pointers as Delphi does. This record pointer works perfect when implemented in Delphi...

function UnzipFiles(var Files: TUnzipFiles; const Silent: Bool): Bool; stdcall;
  external 'Unzipper.dll';

How can I work with this DLL if Inno Setup doesn't support record pointers?

役に立ちましたか?

解決

There is no need for pointers.
Inno Setup Pascal Script does not support pointers.

The statement:

function UnzipFiles(var Files: TUnzipFiles; const Silent: BOOL): BOOL; external 'UnzipFiles@files:Unzipper.dll stdcall';

Passes Files as a var parameter, which means that what's really passed is a pointer to TUnzipFiles. There is no need to make TUnzipFiles array of pointers.
Just make it a normal array and everything will work.

The solution is to just use an array of the record in question:

TUnzipFiles = array of TUnzipFile;

Now it will work.

Because a var parameter passes a pointer internally your call will not be any slower (or faster).
That's the beauty of Delphi. It hides the complexity of pointers in almost all cases where you'd need it in C.
All objects references and var parameters are really pointers, but you needn't worry about that.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top