Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-01

Becoming crazy with dll

3 messages · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michel Meunier

Hello,

I try to translate a dll from delphi to fpc, but I have a lot of problem. First I am unable to load it with loadlibrary. the code of the library is:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx library dlltest;

{$mode objfpc}{$H+}

uses
Classes

  { add your units here }, dlltestUnit;

exports
AskForExecuteCCDCommand name 'AskForExecuteCCDCommand'; begin
end.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx and the unit associate is:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx unit dlltestUnit;

{$mode objfpc}{$H+}
interface
uses
  Classes, SysUtils;
const
    MaxCommand=100;
type
    // Param structures that is used to pass the data
    // 32 bits Alignement
  TParamCCD = record
    NbreParam: Integer;
    Param: array[0..MaxCommand - 1] of Pchar;
  end;
  PParamCCD = ^TParamCCD; // Pointer
procedure AskForExecuteCCDCommand(ParamCCDInt, ParamCCDOut: PParamCCD);
stdcall; // C-C++ calling conventions
implementation
procedure AskForExecuteCCDCommand(ParamCCDInt, ParamCCDOut: PParamCCD);
stdcall; // C-C++ calling conventions
begin
end;

end.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx next in a small programm I try to load the library, but the handle is allways 0. The part with the code is:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Var HandleDLL:Integer;
begin

HandleDLL := LoadLibrary('dlltest.dll');
 if HandleDLL  0 then
 begin
 showmessage('ok');
 showmessage(inttostr(HandleDLL));
 end
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Thanks a loy for your help, I am becoming crazy with that!

Michel Meunier Web: www.etoiles-a-bleau.fr