在Inno Setup Unicode中使用宽字符指针字段定义结构

时间:2017-07-27 11:43:08

标签: inno-setup pascalscript

某些外部库(尤其是Windows API)使用结构类型,其中某些字段是指向字符数组的指针。

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

例如,如何定义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; 

1 个答案:

答案 0 :(得分:0)

使用string类型。在Inno Setup Unicode Pascal Script中,string类型会自动封送到PWideChar - 就像某些上下文中的类型一样:

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

所以SHFILEOPSTRUCT结构的定义是:

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

如需使用,请参阅Inno Setup invoke or replicate native Windows file copy operation

在所有(?)其他上下文中,string使用Pascal语言保留其唯一的内部函数。