Q:  How do I close a file that was opened in a DLL (Delphi made) and called from VB?

A:  This is a known problem. It comes from the fact that VB closes the 5 DOS standard handles (0..4) at startup. So the open file routine will reuse one of these handles to open the first disk file. That is not a problem in using the file, but the Pascal Close routine has a build-in safety feature: it refuses to close a file that has one of the standard handles! That is a Good Thing under DOS but screws up the works in your situation since the file opened by the DLL is never closed, not even when the DLL goes down! VC++ is obviously less restricted and will close a standard handle.

You can fix this problem yourself.  Instead of using the Pascal Close/CloseFile routine to close the file in the DLL use this one:

Procedure ReallyCloseFile(Var F); Assembler;
Asm
  les bx, F
  mov bx, es:[bx]
  mov ah, $3E
  call Dos3Call
End;