Problem with VB5 calling D2 DLL routine

Problem with VB5 calling D2 DLL routine

Post by Kenny Ta » Sun, 31 Dec 1899 09:00:00

Hi all,

I've a routine in DLL (involving BDE operations like TTable navigation,
written in Delphi 2.01, and it works perfectly with a Delphi 2 EXE (it
better be).

However, when I try calling it from a VB5 compiled executable, it throws
a GPF whenever I tried to open a TTable object (I have left traces in the
routine and found out abt this).  The DLL routine did not even have any
parameters, and it's compiled with "stdcall" calling convention.  The codes
look something like this :

library MyDLL;

  test in 'test.pas';

function MyRoutine : Integer; export; stdcall;

  MyRoutine index 1;


unit test;


  SysUtils, DBTables, Dialogs;

function MyRoutine : Integer; export; stdcall;


function MyRoutine : Integer;
  MyTable : TTable;
    MyTable := TTable.Create(Nil);
    with MyTable do begin
      DatabaseName := <MyAlias>;
      TableName := <MyTableName>;
      Active := True;   (* GPF struck here ! *)
    MyTable.Active := False;


Did I miss out anything important or is it a known problem of BDE ?
I'm using BDE 3.0 which comes with Delphi 2.01.

Thanks in advance,


1. Problem with DLL called from VB5.0

        I have written my DLL in VC 5.0 for my VB 5.0 application. I faced so
funny problem. In my program I wanted to call the DLL in four nested for
loop about 4620 times. If I hard coded the number of the time the for loop,
then I can call the DLL for about 100 times without any problem or erro
come out. Then if I used the value input from the user from sliding bar
which is in percentage of the total amount of the time the DLL to be
called, I multiply the percentage with the total amount which is 4620 and
get the integer of it. And when I try to run the DLL the number of the
times the user specify I can only run the DLL for 20-25 times only and
error occur.
        The error is sa follow:
Mircosoft Visual C++ debug library
        Debug Error!!
        Program D:\VB5\Vb5.exe

        DAMAGE: after Normal block  (#321) as 0x01CD0CD0

        Press retry to debug the application.

        When I press the retry button the following error come out:

        This program has performed an illegal operation and will be shut down.

        I click on the details button and the following details is given:

        VB5 caused an exeption 03H in module SPEECH.DLL at 014f:100005df0 and all
the register value and other stuff.

        When I try to debug it, Visual C++ is started and it bring to me to the
function called void __cdecl _free_dbg_lk in the file calledDbgheap.c and
it show a message like this "User breakpoint called from code at

        In the function is have this code :

            if (!CheckBytes(pbData(pHead) + pHead->nDataSize,
_bNoMansLandFill, nNoMansLandSize))
                _RPT3(_CRT_ERROR, "DAMAGE: after %hs block (#%d) at
                    (BYTE *) pbData(pHead));

there is an arrow point to the last line of the code (BTYE) .....

        I am not sure what is wrong with it. Can only body please help me? Thanks
for the time. Why is this happending? What cause it to happen? How can I
fix this problem? What is the exception 03H mean? Which part of the program
I need to change? Is it in VB or in the DLL?

Keat Jau
Final year Computer Engineering student at
University of Newcastle


3. Calling external MSWindows DLL routines form progress v7.3

4. MDAC version

5. Call Delphi's DLLS routines from VFP

6. MSSQLServer Service changes to Disabled

7. ODBC32.dll API calls in VB5 Pro

8. Oracle developer 6i duties

9. Entended SP calls DLL which calls MSMQ -- problem

10. Help: problem with NT DLL RAS routine and DAO

11. Problems calling C++ routines from PL/SQL

12. problem on calling a procedure routine

13. SPEED: VB5 ActiveX DLL vs C++ ATL COM DLL