I have some code in an application that calls GetTempFileName to get a
filename from Windows. To do this it uses the following

var
    TmpPath,TmpName:PChar;
begin
     GetMem(TmpPath,MAX_PATH+1);
     if GetTempPath(MAX_PATH,TmpPath)<>0 then
     begin
          GetMem(TmpName,MAX_PATH+1);
          if GetTempFileName(TmpPath,PChar('AD_'),0,TmpName)<>0 then
          begin
[...]
                    Compressor.CompressFile(TmpName^),CurrentFile,coLZH5);
          end;
          FreeMem(TmpPath);
     end;
     FreeMem(TmpName);
     end;
end;

But what happens is that the file gets created but comes out as a zero
length file (never written).

This works though:

Compressor.CompressFile(String(TmpName),CurrentFile,coLZH5);

What is the practical difference in the parameter, i.e. the difference
between passing the dynamic variable directly and casting it to
a string first?

============================================
Patrick Dunford, Christchurch, NZ
http://patrick.dunford.com/
"These are they who have come out of the great tribulation;
they have washed their robes and made them white in the
blood of the Lamb" - Revelation 7:14

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to