【问题标题】:Undeclared identifier : TExplicitAccess in Delphi 5未声明的标识符:Delphi 5 中的 TExplicitAccess
【发布时间】:2015-12-08 01:25:25
【问题描述】:

我正在尝试更改 Delphi 5 中文件夹的权限,以便每个人都可以修改访问它,但是,我在网络上找到的每个指南都使用 TExplicitAccess 类型,并且它在 Delphi 5 中作为未声明的标识符出现。如果有人知道原因,我很想知道。

顺便说一句,升级到新的 Delphi 版本不是一种选择,我需要能够在 Delphi 5 中执行此操作。

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

【问题讨论】:

    标签: delphi delphi-5 undeclared-identifier


    【解决方案1】:

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

    在 Delphi 5 中,类型在 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 上提供。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-31
      • 1970-01-01
      相关资源
      最近更新 更多