Board index » delphi » Difference D4 vs D5...

Difference D4 vs D5...

Hello,

I'm writing a DLL, which in turn calls another DLL(third-party).
The DLL is supposed to create a special file type, using the third-party
DLL.
If I build my DLL in D4, everything works perfectly (My result file works
fine), yet if I build it in D5 (No changes at all), my DLL creates a
corrupted file.
My guess is, that there is a difference between D4 and D5 in calling a DLL
with LoadLibrary.
Here are some code snippets.... Hope someone can figure this out.

unit Unit2;
interface

uses windows, mapi ;

file://Procedures to handle dynamic loading of migrid.dll
procedure OpenDLL;
procedure CloseDll;

type
TCreateFile= function(Handler : HWND; Filename : pchar;dMaxVal :double):
boolean ; stdcall;

var
CreateFile: TCreateFile;

implementation

procedure OpenDLL;
var Handle:Integer;
begin
  Handle := LoadLibrary(Pchar(ThirdPartyDir + 'Special.dll'));
  if Handle <> 0 then
  begin
    @CreateFile:= GetProcAddress(Handle, 'CreateFile');
  end;
end;

procedure CloseDLL;
var Handle:Integer;
begin
  Handle := LoadLibrary(Pchar(ThirdPartyDir + 'Special.dll'));
  if Handle <> 0 then
  begin
        FreeLibrary(Handle);
  end;

 

Re:Difference D4 vs D5...


<Mar...@NIGZ.nl> skrev i en meddelelse
news:895r7t$8il$1@porthos.nl.uu.net...

Quote
> I'm writing a DLL, which in turn calls another DLL(third-party).
> The DLL is supposed to create a special file type, using the third-party
> DLL.
> If I build my DLL in D4, everything works perfectly (My result file works
> fine), yet if I build it in D5 (No changes at all), my DLL creates a
> corrupted file.
> My guess is, that there is a difference between D4 and D5 in calling a DLL
> with LoadLibrary.

There is no difference as to how you call a DLL in D4 and D5.
I think your problem may be the way the DLL creates the file.
If you use records to write the file, you should know that D4 and D5 align
fields in records differently, which the D5 help also states.
To be able to help you more, please give some details on how you create the
file.

Finn Tolderlund

Other Threads