Board index » delphi » Calling 32-bit DLLs from Delphi 1.0?

Calling 32-bit DLLs from Delphi 1.0?

Hi,

Steve Teixeira has posted a nice unit to do this a while back:

Quote
>Newsgroups: comp.lang.pascal.delphi.misc
>Subject: Re: Calling 32-bit DLLs from Delphi 1.0?
>Date: 7 Jan 1997 21:54:08 GMT
>Message-ID: <01bbfce5$4c16e5e0$8d60b...@stevet.borland.com>

which I cannot get this to work.

In Delphi 1.0 I am trying to:

uses WoW16; { unit posted by Steve Teixeira }
            { Call32NT, another unit doing the same, does exactly
                  the same: GPF... }

procedure TForm1.Button1Click(Sender: TObject);
var
  A32Handle : THandle32;
begin
  A32Handle := LoadLibraryEx32W('e:\c\c_calc\test.dll', 0, 0);
  { This code GPF's wildly - but Win32 (!) exceptions:
      -> page fault in the DLL, see below

    Strangely, sometimes (1 out of 10?) it seems to work, somehow.
  }

  if A32Handle = 0 then
    raise Exception.Create('Error loading DLL');

  ShowMessage('Yes!');

  FreeLibrary32W(A32Handle);
end;

and the C code of the (BC++ 5.01) Win32 DLL is just:

// Pasted from a BC++ example: C DLL -> Delphi 2.
#include <windows.h>

#if defined( __cplusplus)
#define CFUNC extern "C"
#endif

CFUNC bool __export __stdcall Message(const char * msg)
{
   return MessageBox(NULL, msg, "DLL", MB_OK|MB_APPLMODAL);

Quote
}

I tried the original example DLL coming with BC++ 5.01, too (which
works well with Delphi 2, BTW), but the same problems remain.

I do want to have a 32 bit DLL and a 16 bit executable.

Any ideas?
--
Stefan.Hoffmeis...@Uni-Passau.de
http://www.rz.uni-passau.de/~w4hoff01/
University of Passau, Bavaria, Germany

 

Re:Calling 32-bit DLLs from Delphi 1.0?


Quote
Stefan Hoffmeister wrote:
>   A32Handle := LoadLibraryEx32W('e:\c\c_calc\test.dll', 0, 0);
>   { This code GPF's wildly - but Win32 (!) exceptions:
>       -> page fault in the DLL, see below
>     Strangely, sometimes (1 out of 10?) it seems to work, somehow.
    }
> I tried the original example DLL coming with BC++ 5.01, too (which
> works well with Delphi 2, BTW), but the same problems remain.

> I do want to have a 32 bit DLL and a 16 bit executable.

Hi Stefan.

I have been trying to solve this problem for some days now.
Started out with the example in the patch for 5.0 with succefull calls
to BCDLL from Delphi2.0. Just as you say the load of the DLL is instable
maybe 50:50 of the time the DLL is correctly loaded ELSE one get a Page
fault. I sent a way a mail to Steve Texiera - se if I get any reply at
work on monday.
I'am trying to run this on W95. The Page fault indicate some memory
management problem - Do you have to explicitly load the DLL in a sertain
way since the 16-bit EXE recide in one VM and it seams that the DLL live
in it's own 32-bit VM. Even thought the DLL is loaded I can't see that
the DLL is loaded with a DLL-manager.

Any ideas ?

Fredrik Lind
Work: Fredrik.L...@Liber.se  {please answere on this address}    
Home: Fredrik.L...@mailbox.swipnet.se

Other Threads