Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Delph7 und 7Zip.dll Fehler beim Dateidatum auslesen (https://www.delphipraxis.net/176051-delph7-und-7zip-dll-fehler-beim-dateidatum-auslesen.html)

Lemmy 8. Aug 2013 23:45

Delphi-Version: 7

Delph7 und 7Zip.dll Fehler beim Dateidatum auslesen
 
Hallo,

ich "versuche" die 7Zip.dll in Delphi 7 zu verwenden. Dafür verwende ich den Wrapper von Henri Gourvest (https://code.google.com/p/d7zip/). Grundsätzlich funktioniert das Teil, allerdings versuche ich aktuell das Datum der Zip-Items auszulesen. Die DLL stellt dafür folgende Methode bereit:

Delphi-Quellcode:
    function GetProperty(index: Cardinal; propID: PROPID; var value: OleVariant): HRESULT; stdcall;

aber eigentlich kommt da kein OleVariant zurück, sondern ein PROPVARIANT.

Unter XE4 ist das kein Problem:

Delphi-Quellcode:
var LastAcc: PROPVARIANT;
  varOle: OleVariant;
begin
  if Assigned(FInArchiv) then
  begin
    FInArchiv.InArchive.GetProperty(AIndex, kpidLastWriteTime,varOle);
      LastAcc := PROPVARIANT(VarOle);
      result := FileTimeToDateTime(LastAcc.filetime);
...
Allerdings führt der Code unter Delphi 7 bei der Zuweisung an "result" zu einem Fehler:

Ungültiger Variant-Typ

Callstack:
Delphi-Quellcode:
main thread ($e8c):
0046b52d +0b5 Project1.exe Variants        TranslateResult
0046b6d0 +004 Project1.exe Variants        VarResultCheck
0046ba71 +071 Project1.exe Variants        VarClearDeep
0046ba89 +00d Project1.exe Variants        @VarClear
0046ba91 +001 Project1.exe Variants        @VarClr
004af547 +093 Project1.exe pp7Zip  264 +11 TPP7Zip.GetItemLastAccess

d.h. der Fehler tritt beim Aufräumen auf. Setze ich ein VarClar vor die Result-Zuweisung schepperts dann halt da...

Hat jemand eine Idee wie ich das unter D7 zum Laufen bringe?

GRüße

Lemmy 9. Aug 2013 11:58

AW: Delph7 und 7Zip.dll Fehler beim Dateidatum auslesen
 
Tach,

habe das jetzt in Delphi 7 so hin bekommen:

Delphi-Quellcode:
function TPP7Zip.GetItemLastAccess(AIndex: Cardinal): TDateTime;
var LastAcc: PROPVARIANT;
  varOle: OleVariant;
  dtResult: TDateTime;
begin
  if Assigned(FInArchiv) then
  begin
    FInArchiv.InArchive.GetProperty(AIndex, kpidLastWriteTime,varOle);
      LastAcc := PROPVARIANT(VarOle);
      {$IFDEF VER150}
      TVarData(VarOle).VType := varEmpty;
      {$ENDIF}
      result := FileTimeToDateTime(LastAcc.filetime);


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:58 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz