在Inno Setup Unicode中使用宽字符指针字段定义结构 [英] Defining structure with wide character pointer field in Inno Setup Unicode
问题描述
某些外部库(尤其是Windows API)使用结构类型,其中某些字段是指向字符数组的指针.
Some external libraries, notably Windows API, use structure types with some fields being a pointer to a character array.
Inno Setup Unicode没有PChar
(PWideChar
)类型.如何定义使用宽字符数组指针类型的字段的结构?
Inno Setup Unicode does not have PChar
(PWideChar
) type. How do I define a structure, that uses fields of wide character array pointer type?
例如,我如何定义 SHFILEOPSTRUCT
结构?
For example how do I define 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脚本中,string
类型在某些情况下会自动封送为类似PWideChar
的类型:
Use string
type. In Inno Setup Unicode Pascal Script the string
type is automatically marshaled to PWideChar
-like type in some contexts:
- 在
record
定义中(问题所在). - 在
external
函数的参数和返回类型声明中.
- In
record
definitions (what the question is about). - In argument and return-type declarations of
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调用或复制本机Windows文件复制操作.
在所有其他上下文中,string
保留了Pascal语言唯一的内在功能.
In all (?) other contexts, the string
keeps its unique intrinsic function from Pascal language.
这篇关于在Inno Setup Unicode中使用宽字符指针字段定义结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!