Mal abgesehen davon ist die Deklaration von GetFolderIds in ShlObj falsch! Die anderen habe ich jetzt nicht überprüft.
Richtig wäre
Delphi-Quellcode:
type
IKnownFolderManager = interface(IUnknown)
[SID_IKnownFolderManager]
function FolderIdFromCsidl(nCsidl: Integer;
var pfid: TKnownFolderID): HRESULT; stdcall;
function FolderIdToCsidl(const rfid: TIID;
var pnCsidl: Integer): HRESULT; stdcall;
function GetFolderIds(out ppKFId: PGUIDList;
var pCount: UINT): HRESULT; stdcall;
function GetFolder(const rfid: TIID;
out ppkf: IKnownFolder): HRESULT; stdcall;
function GetFolderByName(pszCanonicalName: LPCWSTR;
out ppkf: IKnownFolder): HRESULT; stdcall;
function RegisterFolder(const rfid: TIID;
var pKFD: TKnownFolderDefinition): HRESULT; stdcall;
function UnregisterFolder(const rfid: TIID): HRESULT; stdcall;
function FindFolderFromPath(pszPath: LPCWSTR; mode: FFFP_MODE;
out ppkf: IKnownFolder): HRESULT; stdcall;
function FindFolderFromIDList(pidl: PItemIDList;
out ppkf: IKnownFolder): HRESULT; stdcall;
function Redirect(const rfid: TIID; hwnd: HWND; flags: TKFRedirectFlags;
pszTargetPath: LPCWSTR; cFolders: UINT; var pExclusion: TKnownFolderID;
var ppszError: LPWSTR): HRESULT; stdcall;
end;
type
TKnownFolderManager = class
public
class function CreateInstance: IKnownFolderManager;
end;
class function TKnownFolderManager.CreateInstance: IKnownFolderManager;
begin
if CoCreateInstance(CLSID_KnownFolderManager, nil, CLSCTX_INPROC_SERVER, IID_IKnownFolderManager, Result) <> S_OK then begin
result := nil;
end;
end;
procedure TForm254.Button1Click(Sender: TObject);
var
io : IKnownFolderManager;
count : Cardinal;
vielefolder : PGUIDList;
begin
io:=TKnownFolderManager.CreateInstance;
io.GetFolderIds(vielefolder, count);
Memo1.Lines.Add(' Anz:'+inttostr(count));
CoTaskMemFree(vielefolder);
end;