HPW
New Member
Posts: 14
|
Post by HPW on Mar 7, 2004 5:14:45 GMT -5
I try to write a delphi DLL to be able to zip PChar's from a Lisp-enviroment. Since the Dll creates no forms, I want to create the VclZip instance on the fly. But I get crashes.
Any hint?
FUNCTION ZipString( const ZipNamestr, FileNamestr, InStringVar, Pword : PChar) : PChar; stdcall; VAR tmpstring : STRING; zipstring : STRING; filestring : STRING; VCLZip1 : TVclZip; begin zipstring := StringReplace (ZipNamestr,'/','\',[rfReplaceAll, rfIgnoreCase]); filestring := StringReplace (FileNamestr,'/','\',[rfReplaceAll, rfIgnoreCase]); VCLZip1.Create(nil); With VCLZip1 do begin ZipName := zipstring; Password := Pword; StorePaths := True; PackLevel := 6; ZipFromBuffer(InStringVar, Length(InStringVar), filestring); end; VCLZip1.Destroy; tmpstring := ''; SetStr( Result, tmpstring); end;
|
|
|
Post by Kevin on Mar 7, 2004 10:33:23 GMT -5
I'm not sure if you just made a typo in your message, or if your code is like this too, but where you create the VCLZip object you have:
VCLZip1.Create(nil);
and I believe you really should have:
VCLZip1 := TVCLZip.Create(nil);
Also, you call VCLZip1.Destroy and I believe it is best to call Free rather than call Destroy directly.
See if that helps. If not...
1) what line of code are you getting the exception on 2) what is the exception? 3) what version of Delphi are you using?
|
|
HPW
New Member
Posts: 14
|
Post by HPW on Mar 7, 2004 14:37:38 GMT -5
Thanks Kevin for your fast answer.
And Yes my code was wrong. It happens again not to see the essentials! :-(
But with your help it works now as expected.
I use Delphi 5 Standard for this (Delphi 7/8 update has arrived, but produce slightly bigger Dll's and is not needed for this project). Debugging Dll's is not so easy since no delphi-IDE is more running. I get only a crash from the lisp-enviroment.
PS: I used a non-existent ZIPname-path. With that it crashes also. Is it not allowed? Of cource no problem. I can check it before.
Regards Hans-Peter
|
|
|
Post by Kevin on Mar 8, 2004 8:02:25 GMT -5
You should make sure the path for ZipName exists. VCLZip does not create that.
|
|