asagidaki kodda Dll i dinamik olarak yukluyorum. child form gorunuyor fakat daha sonra program kırılıyor.Bu program gecersiz bir islem yaptı diyerek cıkıyor..
sorun ne olabilir..?????
-------------------- -------------------- -------------------- --------------------
###DLL KODU###
Kod: Tümünü seç
library export;
uses
SysUtils,
Classes,
windows,
forms,
dialogs,
Unit1 in 'Unit1.pas' {Form1}; {burası yuklenecek bos bir form ,mdi child yani}
{$R *.res}
var
DllApp:Tapplication;
procedure MyDLLProc(Reason: Integer);
begin
if Reason = DLL_PROCESS_DETACH then
if Assigned(DllApp) then
Application := DllApp;
end;
procedure ShowMDIChild(MainApp : TApplication);
var
Child : TForm1;
begin
if not Assigned(DllApp) then
begin
DllApp := Application;
Application := MainApp;
end;
Child := TForm1.Create(Application);
try
Child.Show;
//ShowWindow(Child.Handle,SW_SHOW);
except
messagedlg('Sorun Var',mtWarning,mbOKCancel,0);
end;
end;
exports
ShowMDIChild;
begin
DLLProc := @MyDLLProc;
end.
###CAGIRDIGIM FONK####
function TMnFrm.LoadDll(DllPath:String):boolean;
type
TShowMdiChild = procedure(MainApp : TApplication);stdcall;
var
DLLInstance : THandle;
ShowMdiChild: TShowMdiChild;
begin
DLLInstance := LoadLibrary(PChar(DllPath));
if DLLInstance = 0 then begin
MessageDlg('Dll Yok!.', mtError, [mbOK], 0);
Result:=False;
Exit;
end;
@ShowMdiChild := GetProcAddress(DLLInstance, 'ShowMDIChild');
if @ShowMdiChild <> nil then
begin
Result:=True;
ShowMdiChild(Application)
end
else
MessageDlg('Procedure veya Fonksiyon Bulunamadi.', mtError, [mbOK], 0);
FreeLibrary(DLLInstance);
end;
procedure TMnFrm.DosyayaVer1Click(Sender: TObject);
begin
LoadDll('export.dll');
end;