如何检查 Delphi 中枚举的 IStorage 元素的类型?

How can I check the type of the enumerated IStorage element in Delphi?

我需要使用 Delphi 中的 IStorageIStream 接口 7. 我需要 IStorage 实例中的存储和流的名称列表。如果我尝试像这样收集它们:

procedure TStorageUtility.collectElementNamesByType( iStg_ : IStorage; names_ : TStringList; type_ : byte );
var
  enum : IEnumSTATSTG;
  rec : StatStg;
  num : integer;
begin
  if ( iStg_.enumElements( 0, NIL, 0, enum ) = S_OK ) then
    while ( enum.next( 1, rec, @num ) = S_OK ) do
    begin
      if ( rec.type = type_ ) then
        names_.add( wideString( rec.pwcsName ) );
    end;
end;

我收到编译器错误:

Identifier expected but 'TYPE' found

if ( rec.type = type_ ) then

这里是 STATSTG 记录定义:https://msdn.microsoft.com/en-us/library/windows/desktop/aa380319(v=vs.85).aspx

如何在没有任何编译器错误消息的情况下检查记录类型?

好的。 MSDN 文档(针对 Delphi 用户)具有误导性。 STATSTG 的这个字段在 ActiveX 单元中按名称 dwType 定义。当我使用它时,它当然会编译。