title: Retrieving Extended File Properties via delphi
body: <p>When you right-click a file in Windows Explorer and select Properties from the menu, a dialog box displays basic properties for that file.</p>
  
  <p>I'm trying to get these properties (keywords, comments, title...) for word files in a folder. </p>
  
  <p>I modified a code that i found somewhere and it works well in vba (MSWord office macro):</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  
  Dim arrHeaders(35)
  
  Set objShell = CreateObject("Shell.Application")
  Set objFolder = objShell.Namespace("C:\Scripts")
  
  For i = 0 To 34
    arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
  Next
  
  For Each FileName In objFolder.Items
    For i = 0 To 34
      MsgBox i &amp; vbTab &amp; arrHeaders(i) &amp; ": " &amp; objFolder.GetDetailsOf(FileName, i)
    Next
  Next
  
  End Sub
  </code></pre>
  
  <p>So I'm trying to make it work in object pascal in delphi. I'm still missing some of the syntax.</p>
  
  <p>I was able to transform half of the syntax:</p>
  
  <pre><code>procedure TFormAFDetails.Button1Click(Sender: TObject);
  var
    ObjShell, ObjFolder : Variant;
    FileProp : array of string;
    FName : String;
    I, J : Integer;
  begin
      SetLength(FileProp, 35);
      ObjShell := CreateOleObject('Shell.Application');
      ObjFolder := ObjShell.NameSpace('C:\Scripts');
  
      for I := 0 to 34 do
        FileProp[I] := ObjFolder.GetDetailsOf(ObjFolder.Items,I);
  
      for FName in ObjFolder.Items do
      begin
        for J := 0 to 34 do
          ShowMessage(FileProp[J]+' : '+ObjFolder.GetDetailsOf(FName,J));
      end;
  end;
  </code></pre>
  
  <p>The part "for - in - do" won't work as it says </p>
  
  <pre><code>//for -in statement can't operate on collection type 'variant' 
  </code></pre>
  
  <p>Can anyone help me out please?</p>