002
02.03.2008, 21:53 Uhr
~Tobias_H
Gast
|
ja danke, hat schon etwas geholfen
ich kriege alles ausgelesen, nur nicht die information, die z.b. bei word dokumenten als "Titel" angegeben wird.
was mach ich falsch, ich verstehs nicht, hab mir jett mal alle spalten ausgeben lassen und mir im debug angegeuckt, aber irgendwie ist diese "Titel" spalte ncht dabei.
dachte die DEtailsOf - Methode wäre dafür die richtige
C++: |
// 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 argc, TCHAR* argv[]) {
char path[MAX_PATH] = "C:\\temp\\test";
HRESULT hr; IShellFolder * isfDesktop = NULL; IShellFolder2 * isfCur = NULL;
hr = CoInitialize(NULL); // initialize COM // NOTE: usually COM would be initialized just once in your main()
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_ACP, MB_PRECOMPOSED, path, -1, olePath, MAX_PATH);
// parse path for absolute PIDL, and connect to target folder LPITEMIDLIST pidl = NULL; // general purpose hr = isfDesktop->ParseDisplayName(NULL, NULL, olePath, NULL, &pidl, NULL); LPSHELLFOLDER psfFolder = NULL; hr = isfDesktop->BindToObject(pidl, NULL, IID_IShellFolder, (void**)&psfFolder); isfDesktop->Release(); // no longer required pMalloc->Free(pidl);
LPENUMIDLIST penumIDL = NULL; // IEnumIDList interface for reading contents hr = psfFolder->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &penumIDL); while(1) { // retrieve a copy of next local item ID list hr = penumIDL->Next(1, &pidl, NULL);
if(hr == NOERROR) { WIN32_FIND_DATA ffd; // let's cheat a bit :) hr = SHGetDataFromIDList(psfFolder, pidl, SHGDFIL_FINDDATA, &ffd, sizeof(WIN32_FIND_DATA));
SHELLDETAILS sd; hr = isfCur->GetDetailsOf(pidl, 0, &sd); hr = isfCur->GetDetailsOf(pidl, 1, &sd); hr = isfCur->GetDetailsOf(pidl, 2, &sd); hr = isfCur->GetDetailsOf(pidl, 3, &sd); hr = isfCur->GetDetailsOf(pidl, 4, &sd); hr = isfCur->GetDetailsOf(pidl, 5, &sd); hr = isfCur->GetDetailsOf(pidl, 6, &sd); hr = isfCur->GetDetailsOf(pidl, 7, &sd);
cout << "Name = " << ffd.cFileName << endl; cout << "Type = " << ( (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? "dir\n" : "file\n" ); cout << "Size = " << ffd.nFileSizeLow << endl; pMalloc->Free(pidl); } // the expected "error" is S_FALSE, when the list is finished else break; }
// release all remaining interface pointers penumIDL->Release(); psfFolder->Release(); pMalloc->Release();
CoUninitialize(); // shut down COM
return 0; }
|
|