IDAPI hangs on Win3.x machines when sharing TTables through DLL's
Hello,
I have a DLL with the following procedure:
unit Dlltabu1;
interface
uses DBTables;
var aTable:TTable;
procedure AddRecord; export;
implementation
uses DB,Dialogs,SysUtils;
procedure AddRecord;
var Highest:LongInt;
begin
TRY
WITH aTable DO
BEGIN
IF RecordCount=0 THEN
Highest:=0
ELSE
BEGIN
Last;
Highest:=FieldByName('MsgID').AsInteger;
END;
Append;
FieldByName('MSGType').AsString:='O';
FieldByName('MsgID').AsInteger:=Highest+1;
Post;
END;
EXCEPT
ON E:Exception DO
ShowMessage('Exception message: '+E.Message);
END;
end;
procedure DestroyTable; far;
begin
IF aTable<>NIL THEN
BEGIN
aTable.Close;
aTable.Free;
END;
aTable:=NIL;
end;
Initialization
aTable:=TTable.Create(NIL);
aTable.TableName:='TEST.DB';
aTable.DatabaseName:='C:\';
AddExitProc(DestroyTable);
end.
I also have an .EXE which calls the AddRecord procedure in the DLL.
Everything works until a second instance of this EXE is launched. When
two instances of this EXE are running, only the calls from the 1st
instance to AddRecord succeeds. The calls from the second instance raise
an exception on the first method call on the aTable variable in the DLL.
The exception generated is "Lock time out".
The strange thing is that this problem only occurs on Win3.x machines
and not on Win95 machines.
I have also copied the full idapi installation from the 95 machine to
the 3.11 machine, but to no avail. The problem persists on the Win3.11
machine. One thing I noted is that on the Win3.11 machine IDAPI
generates PARADOX.LCK and PDOXUSRS.LCK files in the root directory on
the first append. This does not happen on the WIN95 machine.
Does anybody know the reasons to this strange behaviour ?
--
------------------------------------------------------
Rik Gruwez
gru...@unicall.be
http://uc2.unicall.be/gruwez
"There is no substitute for cubes"
------------------------------------------------------