Announcement

Collapse
No announcement yet.

Titel eines Dokumentes auslesen

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Titel eines Dokumentes auslesen

    hi,

    ich versuche aus einem ordner mir alle dokumente auszulesen und den "Titel" den diese besitzen. Ich mein den Text den man sich bei der Detailansicht anzeigen lassen kann.

    da ich leider wirklich fast keine ahnung von COM oder shell habe, hänge ich etwas hilflos in der luft herum

    hab mir durch programmschnipsel geschaft eine anwendung zusammen zu suchen, die mir alles ausliest bis eben diese besage information. ich schaffe es mir dokumentenname, erstellungs-, änderungs-, letzeszugriffsdatum auszulesen sowie den dokumentyp, aber nicht den titel.

    hier mal mein Code, was mach ich falsch, jemand neinen tipp was ich machen muss um an den dokumentitel zu kommen?

    habe mir einfach mal alles ausgeben lassen, über das ich die ID nummern des Befehls GetDetailsOf(pidl, 8, &sd) dran komme, aber schon ab ID 7 liefert die Funktion S_FALSE zurück.

    PHP Code:
    // ListDirCon.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
    //

    #include "stdafx.h"
    #include "windows.h"
    #include "shlobj.h"
    #include <iostream>

    using namespace std;

    int _tmain(int argcTCHARargv[])
    {

    char path[MAX_PATH] = "C:\\temp\\test";

        
    HRESULT hr;
        
    IShellFolder isfDesktop NULL;
        
    IShellFolder2 isfCur NULL;

       
    hr CoInitialize(NULL); // initialize COM

       
    LPMALLOC pMalloc NULL// memory manager, for freeing up PIDLs
       
    hr SHGetMalloc(&pMalloc);
       
       
    hr SHGetDesktopFolder(&isfDesktop);
       
    isfDesktop->QueryInterface(IID_IShellFolder2, (LPVOID*)&isfCur);

       
    // IShellFolder::ParseDisplayName requires the path name in Unicode.
       
    OLECHAR olePath[MAX_PATH]; // wide-char version of path name
       
    MultiByteToWideChar(CP_ACPMB_PRECOMPOSEDpath, -1olePathMAX_PATH);

       
    // parse path for absolute PIDL, and connect to target folder
       
    LPITEMIDLIST pidl NULL// general purpose
       
    hr isfDesktop->ParseDisplayName(NULLNULLolePathNULL, &pidlNULL);
       
    LPSHELLFOLDER psfFolder NULL;
       
    hr isfDesktop->BindToObject(pidlNULLIID_IShellFolder
                                     (
    void**)&psfFolder);
       
    isfDesktop->Release(); // no longer required
       
    pMalloc->Free(pidl);

       
    LPENUMIDLIST penumIDL NULL// IEnumIDList interface for reading contents
       
    hr psfFolder->EnumObjects(NULLSHCONTF_FOLDERS SHCONTF_NONFOLDERS
                                   &
    penumIDL);
       while(
    1) {
          
    // retrieve a copy of next local item ID list
          
    hr penumIDL->Next(1, &pidlNULL);

          if(
    hr == NOERROR) {
             
    WIN32_FIND_DATA ffd
             
    hr SHGetDataFromIDList(psfFolderpidlSHGDFIL_FINDDATA, &ffd
                                      
    sizeof(WIN32_FIND_DATA));

             
    SHELLDETAILS sd;


             
    hr isfCur->GetDetailsOf(pidl0, &sd);
             
    wcout<<sd.str.pOleStr<<endl;
             
    hr isfCur->GetDetailsOf(pidl1, &sd);
             
    wcout<<sd.str.pOleStr<<endl;
             
    hr isfCur->GetDetailsOf(pidl2, &sd);
             
    wcout<<sd.str.pOleStr<<endl;
             
    hr isfCur->GetDetailsOf(pidl3, &sd);
              
    wcout<<sd.str.pOleStr<<endl;
             
    hr isfCur->GetDetailsOf(pidl4, &sd);
              
    wcout<<sd.str.pOleStr<<endl;
             
    hr isfCur->GetDetailsOf(pidl5, &sd);
              
    wcout<<sd.str.pOleStr<<endl;
             
    hr isfCur->GetDetailsOf(pidl6, &sd);
              
    wcout<<sd.str.pOleStr<<endl;
             
    hr isfCur->GetDetailsOf(pidl7, &sd);
              
    wcout<<sd.str.pOleStr<<endl;
             
    hr isfCur->GetDetailsOf(pidl8, &sd);
              
    wcout<<sd.str.pOleStr<<endl;
             
    hr isfCur->GetDetailsOf(pidl9, &sd);
              
    wcout<<sd.str.pOleStr<<endl;

             
    wcout << L"Name = " << ffd.cFileName << endl;
             
    wcout << L"Type = " << ( (ffd.dwFileAttributes FILE_ATTRIBUTE_DIRECTORY)
                                    ? 
    "dir\n" "file\n" );
             
    wcout << L"Size = " << ffd.nFileSizeLow << endl;
             
             
    pMalloc->Free(pidl);
          }
          else break;
       }

       
    // release all remaining interface pointers
       
    penumIDL->Release();
       
    psfFolder->Release();
       
    pMalloc->Release();

       
    CoUninitialize(); // shut down COM



        
    return 0;

Working...
X