在 Inno Setup Unicode 中定义具有宽字符指针字段的结构

Defining structure with wide character pointer field in Inno Setup Unicode

一些外部库,特别是 Windows API,使用结构类型,其中一些字段是指向字符数组的指针。

Inno Setup Unicode 没有 PChar (PWideChar) 类型。如何定义一个使用宽字符数组指针类型字段的结构?

例如我如何定义SHFILEOPSTRUCT structure

type
  TSHFileOpStruct = record
    hwnd: HWND;
    wFunc: UINT;
    pFrom: { what type? }
    pTo: { what type? }
    fFlags: Word;
    fAnyOperationsAborted: BOOL; 
    hNameMappings: HWND;
    lpszProgressTitle: { what type? }
  end; 

使用string类型。在 Inno Setup Unicode Pascal Script 中,string 类型在某些情况下自动编组为 PWideChar-like 类型:

  • record 定义中(问题是关于什么的)。
  • external functions 的参数和 return 类型声明中。

所以SHFILEOPSTRUCT结构的定义是:

type
  TSHFileOpStruct = record
    hwnd: HWND;
    wFunc: UINT;
    pFrom: string;
    pTo: string;
    fFlags: Word;
    fAnyOperationsAborted: BOOL; 
    hNameMappings: HWND;
    lpszProgressTitle: string;
  end; 

有关用途,请参阅

在所有(?)其他上下文中,string 保留了 Pascal 语言的独特内在功能。