Einzelnen Beitrag anzeigen

BlueStarHH

Registriert seit: 28. Mär 2005
Ort: Hannover-Hainholz
801 Beiträge
 
Delphi 11 Alexandria
 
#18

Re: Erweiterte Dateiinformationen schreiben

  Alt 22. Jul 2009, 20:35
Ich nutze jetzt folgenden Code um die FileSummaryInfos unter Delphi 2009 auszulesen. Wie kann ich das unicode-kompatibel machen? Wenn in den FileSummaryInfos Unicode gespeicher ist kommen mit dieser Funktion nur kryptische falsche Zeichen zurück:

Delphi-Quellcode:
function GetFileSummaryInfo(const FileName: WideString;
  GUID_SummaryType: TGUID; PID_InfoType: cardinal): string;
var
  hr : HRESULT;
  Stg : IStorage;
  PropSetStg : IPropertySetStorage;
  PropStg : IPropertyStorage;
  PropSpec : TPropSpec;
  PropVariant : TPropVariant;
begin
  Result := '';
  hr := S_FALSE;


  // for 9x and NT4 users
  if(not Win2k) or (@StgOpenStorageEx = nil) then
    hr := StgOpenStorage(pwidechar(FileName),nil,STGM_READ or
      STGM_SHARE_DENY_WRITE,nil,0,Stg)
  // for 2000, XP and higher
  else if(@StgOpenStorageEx <> nil) then
    hr := StgOpenStorageEx(pwidechar(FileName),STGM_READ or
      STGM_SHARE_DENY_WRITE,STGFMT_ANY,0,nil,nil,
      @IID_IPropertySetStorage,Stg);


  if(hr = S_OK) then
  begin
    PropSetStg := Stg as IPropertySetStorage;

    if(PropSetStg.Open(GUID_SummaryType,STGM_READ or
      STGM_SHARE_EXCLUSIVE,PropStg) = S_OK) then
    begin
      PropSpec.ulKind := PRSPEC_PROPID;
      PropSpec.propid := PID_InfoType;


      if(PropStg.ReadMultiple(1,@PropSpec,@PropVariant) = S_OK) and
        (PropVariant.vt = VT_LPSTR) and
        (PropVariant.pszVal <> nil) then
      Result := PropVariant.pszVal;
    end;
  end;
end;
  Mit Zitat antworten Zitat