GPF on DLL+BDE unload

Dear Sirs,

I've got a problem with trying to use BDE from a DLL. This DLL generates
a GPF when unloading, but only if TestProc was called. TestProc contains
the following code and nothing else:

   DbiInit( nil );
   DbiDllExit;
   DbiExit;

TestProc itself executes apparently successfully.
Does someone know what could be the cause of this GPF ?

One friend suggested that he remembers reading somewhere that there was
something to be done with DS register when calling BDE from Delphi DLL,
but he doesn't remember exactly what and where.

Here is the whole source of the DLL in question:

{file test.pas}
unit test;

interface

Procedure TestProc; stdcall; export;

implementation

Uses
    BDE;

Procedure TestProc;
begin
   DbiInit( nil );
   DbiDllExit;
   DbiExit;
end;

end.
----------------------------------
{file BDE_Test.DPR}
library BDE_Test;

uses
  ShareMem,
  test in 'test.pas';

exports
  TestProc;

begin
end.

Thanks in advance,
Gedas