Thema: Delphi Dll Problem

Einzelnen Beitrag anzeigen

mr.unbekannt

Registriert seit: 20. Jul 2005
Ort: Schwerin
152 Beiträge
 
Delphi 7 Professional
 
#1

Dll Problem

  Alt 19. Jun 2007, 18:40
Hi @all,

ih habe ein Problem beim laden einer dll. nachfolgend erstmal den quelltext der dll und des projectes:
Delphi-Quellcode:
unit main;

interface

uses
  sharemem,Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls, extctrls;

type
  Tfmmain = class(TForm)
    PageControl1: TPageControl;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public

    { Public declarations }
  end;
  TShow_DLLForm = procedure; stdcall;

var
  fmmain: Tfmmain;
  Show_DLLForm: TShow_DLLForm;

implementation


{$R *.dfm}

procedure Tfmmain.Button1Click(Sender: TObject);
var
  dllhandle: Thandle;

begin
  dllhandle := 0;
  try
    dllhandle := LoadLibrary('Project1.dll');
    @Show_DLLForm := GetProcAddress(dllhandle,'startdll');
    if @Show_DLLForm <> nil then
      Show_DLLForm;
  finally
    FreeLibrary(dllhandle);
    showmessage('fertsch');
  end;

end;


end.
Delphi-Quellcode:
library Project1;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }



uses
  sharemem,
  SysUtils,
  Classes,
  dialogs,
  comctrls,
  main in 'main.pas';




{$R *.res}





procedure startdll;
begin
  fmmain.Button1.Caption := 'test';
end;

begin


end.
mein problem ist nun, dass ich die dll lade, aber die procedure Show_DLLForm nil ist und somit nicht ausgeführt wird. wo liegt der fehler? Habe leider bis jetzt keine Erfahrungen mit Dll's
  Mit Zitat antworten Zitat