Defining structure with wide character pointer field in Inno Setup Unicode

六月ゝ 毕业季﹏ 提交于 2020-06-29 13:20:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!