在Inno Setup Unicode中使用宽字符指针字段定义结构 [英] Defining structure with wide character pointer field in Inno Setup Unicode

查看:156
本文介绍了在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆