问题
Some external libraries, notably Windows API, use structure types with some fields being a pointer to a character array.
Inno Setup Unicode does not have PChar
(PWideChar
) type. How do I define a structure, that uses fields of wide character array pointer type?
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;
回答1:
Use string
type. In Inno Setup Unicode Pascal Script the string
type is automatically marshaled to PWideChar
-like type in some contexts:
- In
record
definitions (what the question is about). - In argument and return-type declarations of external functions.
So the definition of SHFILEOPSTRUCT
structure is:
type
TSHFileOpStruct = record
hwnd: HWND;
wFunc: UINT;
pFrom: string;
pTo: string;
fFlags: Word;
fAnyOperationsAborted: BOOL;
hNameMappings: HWND;
lpszProgressTitle: string;
end;
For a use, see Inno Setup invoke or replicate native Windows file copy operation.
In all (?) other contexts, the string
keeps its unique intrinsic function from Pascal language.
来源:https://stackoverflow.com/questions/45349841/defining-structure-with-wide-character-pointer-field-in-inno-setup-unicode