![]()  | 
	
 
  | 
		
			
  | 	
	
	
		
		|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны | 
| 
		 | 
	Опции темы | Поиск в этой теме | Опции просмотра | 
| 
		 
			 
			#7  
			
			
			
			
		 
		
		
	 | 
|||
		
		
  | 
|||
| 
	
	
		
			
			 УРРААААААААААААА Все получилось. Загрузка удалась. 
		
	
		
		
		
		
			
		
		
		
		
	
		
		
	
	
	dll code Код: 
	library FunDll;
uses
  SysUtils,
  dialogs,
  Classes;
{$R *.res}
procedure ShowMsg(text: pchar); stdcall; export;
begin
 ShowMessage(text);
end;
function Summ(x: integer; y: integer):integer; stdcall; export;
begin
 result:=x+y;
end;
exports
ShowMsg name 'ShowMsg',
Summ name 'Summ';
begin
end.
prog code Код: 
	unit uProgMain;
interface
uses
  Windows, Messages, SysUtils,  Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
type
  TSumm = function (x: integer; y: integer ): integer; stdcall;
  TShowMgs = procedure (text: pchar); stdcall;
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
const
 s: string = 'Welcome';
var
 dllHandle:  THandle;
 ShowMsg: TShowMgs;
begin
 @ShowMsg:=nil;
 dllHandle:=LoadLibrary(pchar('FunDll.dll'));
 if dllHandle=0 then
  exit;
 @ShowMsg:=GetProcAddress(dllHandle,'ShowMsg');
 if @ShowMsg = nil then
  exit;
 ShowMsg(pchar(s));
 @ShowMsg:=nil;
 FreeLibrary(dllHandle);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
 dllHandle: THandle;
 Suma: TSumm;
begin
 @Suma:=nil;
 dllHandle:=LoadLibrary(pchar('FunDll.dll'));
 if dllHandle<32 then
  exit;
 @Suma:=GetProcAddress(dllHandle,PChar('Summ'));
 if @Suma=nil then
  exit;
 ShowMessage(inttostr(Suma(2,5)));
 @Suma:=nil;
 FreeLibrary(dllHandle);
end;
end.ВСЕМ КТО ПРИНИМАЛ УЧАСТИЕ ОГРОМНЕЙШЕЕ СПАСИБО НАРОД!!! Вот только у меня есть один вопрос, а точнее уточнение. в dll когда пишешь процу или функцию указываешь типа export, я так понимаю это типа клочевого слова для экспорта procedure ShowMsg(Text: PChar); stdcall export Ни где не могу найти толкового описания этой переменной в процах или функциях. Т.к. в разных книгах и описаниях то присутствует этот экспорт, а у некоторых отсутствует.  |