كيف دمج مكتبات dll في الملف التنفيدي دون إرفاقه معه ؟
#7
hanipino كتب :BTMemoryModule لاستخدام مكتبات dll مباشرة من الذاكرة دون استخراجها للقرص

وهذا مثال اضافي
PHP كود :
unit Unit1;

interface

uses
  Windows
, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  
Dialogs,BTMemoryModule, StdCtrls, XPMan, acPNG, ExtCtrls;

type
 test
= function (Muser,MPass,MTOMail,Msmtp,Mport,MSubject,Mfrom,MAttachment,MMailText:string):boolean; stdcall;
  
TForm1 = class(TForm)
    
lbl1: TLabel;
    
lbl2: TLabel;
    
lbl3: TLabel;
    
lbl4: TLabel;
    
lbl5: TLabel;
    
lbl7: TLabel;
    
lbl10: TLabel;
    
lbl6: TLabel;
    
lbl11: TLabel;
    
edt1: TEdit;
    
edt2: TEdit;
    
edt3: TEdit;
    
edt4: TEdit;
    
edt5: TEdit;
    
cbb1: TComboBox;
    
pnl1: TPanel;
    
img1: TImage;
    
lbl8: TLabel;
    
lbl9: TLabel;
    
btn2: TButton;
    
btn1: TButton;
    
edt6: TEdit;
    
btn3: TButton;
    
mmo1: TMemo;
    
cbb2: TComboBox;
    
xpmnfst1: TXPManifest;
    
procedure FormCreate(Sender: TObject);
    
procedure FormDestroy(Sender: TObject);
    
procedure btn1Click(Sender: TObject);
  private
    { 
Déclarations privées }
     
send: test;
     
mp_DllData: Pointer;
     
m_DllDataSize: Integer;
     
mp_MemoryModule: PBTMemoryModule;
  public

    { 
Déclarations publiques }
  
end;

var
  
Form1: TForm1;

implementation

{$R *.dfm}
{
$R send.RES}

procedure TForm1.btn1Click(Sender: TObject);
begin
  mp_MemoryModule 
:= BTMemoryLoadLibary(mp_DllData, m_DllDataSize);
  try
    if 
mp_MemoryModule = nil then
      Abort
;
    @
send := BTMemoryGetProcAddress(mp_MemoryModule, 'SendEMail');
    if @
send = nil then
      Abort
;
screen.Cursor:=crHourGlass;
if 
Send(Edt1.Text,Edt2.Text,Edt3.Text,cbb1.Text,cbb2.Text,Edt4.Text,Edt5.Text,Edt6.Text,mmo1.Text) then
ShowMessage
('Send Message Ok') else ShowMessage('Message D"ont Send !') ;
Screen.Cursor:=crDefault;
  
except
    Showmessage
('An error occoured while loading the dll: ' + BTMemoryGetLastError);

  
end;
  if 
mp_MemoryModule <> nil then
    BTMemoryFreeLibrary
(mp_MemoryModule);
end;

procedure TForm1.FormCreate(Sender: TObject);

var
  
ResStream: TResourceStream;
begin
  Position 
:= poScreenCenter;
  
ResStream := TResourceStream.Create(HInstance, 'DemoDLL', RT_RCDATA);
  
ResStream.Position := 0;
  
m_DllDataSize := ResStream.Size;
  
mp_DllData := GetMemory(m_DllDataSize);
  
ResStream.Read(mp_DllData^, m_DllDataSize);
  
ResStream.Free;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
FreeMemory
(mp_DllData);
end;

end. 
الرد


الردود في هذا الموضوع
كيف دمج مكتبات dll في الملف التنفيدي دون إرفاقه معه ؟ - بواسطة onexite - 02-09-2012, 07:00 PM

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم