1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
| procedure TFMain.OnClickDll(sender: TObject);
type
tProcedure = procedure(sBase: pChar; Haut, Largeur: integer);
tRetourDll = function: PInteger;
TSkinDll = procedure(ahandle: HWnd; adata: Pointer);
// Ici on ouvre la fonction principale de la dll ----------
var
HAddOn: LongWord;
s_Query: TIBQuery;
iRetourDll: PInteger;
i: Integer;
SetApp: Tskindll;
ShowFrm: tProcedure;
begin
_FOccupe.doActive;
Screen.Cursor := crHourglass;
doCloseFenetresFlottantes;
Application.ProcessMessages;
iRetourDll := 0;
HAddOn := 0;
// on verifie qu on est bien sur une bonne fiche ---------------------------------------------------------
s_Query := TIBQuery.Create(Application);
with s_Query do
begin
DataBase := dm.ibd_BASE;
SQL.Clear;
SQL.ADD('SELECT * FROM PROC_GESTION_DLL');
Open;
i := FieldByName('CLE_FICHE').AsInteger;
Close;
FreeAndNil(s_Query);
end;
// si on est pas sur une fiche, on sort -------------------
if (i < 1) or (dm.ficheActive < 1) then
begin
ShowMessage('Vous devez d''abord sélectionner un individu....');
exit;
end;
//--------------------------------------------------------------------------------------------------------
bfsbQuitter.Enabled := False;
bfsbRecherche.Enabled := False;
Quitter1.Enabled := False;
FMAin.Enabled := False;
dm.DoUpdateDLL;
// -- Ouverture de la dll --------------------------------------------------------------------------------
if sender.ClassType = TLabel then
begin
if (sender as TLabel).Tag = 999 then
HAddOn := LoadLibrary(pchar(_Path_Appli + _REL_PATH_PLUGINS + (sender as TLabel).Hint))
else if (sender as TLabel).Tag = 998 then
begin
HAddOn := LoadLibrary(pchar(_Path_Appli + _REL_PATH_PLUGINS + (sender as TLabel).Hint));
end;
end
else
HAddOn := LoadLibrary(pchar(_Path_Appli + _REL_PATH_PLUGINS + (sender as TdxBarButton).Description));
// -- si l ouverture se passe bien -----------------------------------------------------------------------
if HAddOn <> 0 then
begin
_FOccupe.doDesactive;
Application.ProcessMessages;
try
@showFrm := GetProcAddress(HAddOn, 'InitStartDll');
@setApp := GetProcAddress(HAddOn, 'SetApplicationHandle');
if @showFrm <> nil then
showfrm(pChar(_Context.PathFileNameBdd), Height - 80, Width - 20);
// La dll est fermée et on recupere le retour de la dll, grace a une methode de la dll
try
iRetourDll := TRetourDll(GetProcAddress(HAddOn, 'RetourDll'));
except
//iRetourDll := PInteger(-10);
end;
if iRetourDll = PInteger(-10) then
dm.doCloseDatabase; //fermeture de la connexion
@setApp := nil;
@showFrm := nil;
if HaddOn <> 0 then
freeLibrary(HaddOn);
HaddOn := 0;
Screen.Cursor := crDefault;
except
showmessage('Erreur d''exécution de la dll');
if HaddOn <> 0 then
freeLibrary(HaddOn);
end;
end;
try
if not dm.ibd_BASE.Connected then
begin
dm.doOpenDatabase;
if CloseModuleActif then
OpenModule(_ID_INDIVIDU);
end;
except
//showmessage('non');
end;
Application.ProcessMessages;
bfsbRecherche.Enabled := True;
FMAin.Enabled := True;
Quitter1.Enabled := True;
bfsbQuitter.Enabled := True;
Application.ProcessMessages;
Screen.Cursor := crDefault;
end; |
Partager