未声明的标识符:Delphi 5 中的 TExplicitAccess

Undeclared identifier : TExplicitAccess in Delphi 5

我正在尝试更改 Delphi 5 中的文件夹权限,以便每个人都可以修改它,但是,我在网上找到的每个指南都使用 TExplicitAccess 类型,并且它出现了out as undeclared identifier in Delphi 5. 如果有人知道为什么,我很想知道。

升级到新的 Delphi 版本不是一个选项,我需要能够在 Delphi 5.

编辑:如下所述,必须使用 EXPLICIT_ACCESS 才能正常工作。谢谢!

即使 Delphi 的最新版本也没有在 Windows header 翻译中声明该类型。大概您的示例代码正在使用第三方 header 翻译。或者,为了方便起见,示例代码可能定义了一个别名。有关详细信息,请参阅您拥有的示例代码。

在Delphi5中,类型声明在AccCtrl单元中。像这样:

{ Definition: EXPLICIT_ACCESS }
{ This structure is used to pass access control entry information into and out }
{ of the system using the API defined in this document. }
{ grfAccessPermissions - This contains the access permissions to assign for the }
{                     trustee.  It is in the form of an NT access mask. }
{ grfAccessMode - This field defines how the permissions are to be applied for }
{                 the trustee. }
{ grfInheritance - For containers, this field defines how the access control }
{                  entry is/(is requested) to be inherited on }
{                  objects/sub-containers created within the container. }
{ Trustee - This field contains the definition of the trustee account the }
{           explicit access applies to. }

  PEXPLICIT_ACCESS_A = ^EXPLICIT_ACCESS_A;
  {$EXTERNALSYM PEXPLICIT_ACCESS_A}
  EXPLICIT_ACCESS_A = packed record
    grfAccessPermissions: DWORD;
    grfAccessMode: ACCESS_MODE;
    grfInheritance: DWORD;
    Trustee: TRUSTEE_A;
  end;
  {$EXTERNALSYM EXPLICIT_ACCESS_A}
  PEXPLICIT_ACCESS_W = ^EXPLICIT_ACCESS_W;
  {$EXTERNALSYM PEXPLICIT_ACCESS_W}
  EXPLICIT_ACCESS_W = packed record
    grfAccessPermissions: DWORD;
    grfAccessMode: ACCESS_MODE;
    grfInheritance: DWORD;
    Trustee: TRUSTEE_W;
  end;
  {$EXTERNALSYM EXPLICIT_ACCESS_W}
  PEXPLICIT_ACCESS_ = PEXPLICIT_ACCESS_A;
  EXPLICIT_ACCESSA = EXPLICIT_ACCESS_A;
  {$EXTERNALSYM EXPLICIT_ACCESSA}
  EXPLICIT_ACCESSW = EXPLICIT_ACCESS_W;
  {$EXTERNALSYM EXPLICIT_ACCESSW}
  EXPLICIT_ACCESS = EXPLICIT_ACCESSA;
  PEXPLICIT_ACCESSA = ^EXPLICIT_ACCESS_A;
  {$EXTERNALSYM PEXPLICIT_ACCESSA}
  PEXPLICIT_ACCESSW = ^EXPLICIT_ACCESS_W;
  {$EXTERNALSYM PEXPLICIT_ACCESSW}
  PEXPLICIT_ACCESS = PEXPLICIT_ACCESSA;

相关结构为EXPLICIT_ACCESS_AEXPLICIT_ACCESS_W。如果你想定义一个方便的别名,你可以这样做:

type
  TExplicitAccess = EXPLICIT_ACCESS_;

然后在AclAPI单元中有各种使用这种类型的函数。

请记住,这些是 Windows API 类型和函数,它们的文档由 Microsoft 在 MSDN 上提供。