Показать сообщение отдельно
  #3  
Старый 31.05.2011, 09:28
Аватар для NumLock
NumLock NumLock вне форума
Let Me Show You
 
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
По умолчанию

Код:
library Project1dll;

uses
  Forms,
  Unit1dll in 'Unit1dll.pas' {Form1};

function ShowModal(s: ShortString): Integer;
begin
  Form1:=TForm1.Create(nil);
  Form1.Caption:=s;
  Result:=Form1.ShowModal;
  Form1.Free;
end;

exports ShowModal;

begin
end.

Код:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  FShowModal: function (s: ShortString): Integer;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  hLibrary: Cardinal;
begin
  hLibrary:=LoadLibrary('Project1dll.dll');
  if hLibrary<>0 then
  begin
    FShowModal:=GetProcAddress(hLibrary, 'ShowModal');
    if @FShowModal<>nil then ShowMessage(IntToStr(FShowModal('ShowMessage')))
    else ShowMessage('!ShowModal');
    FreeLibrary(hLibrary);
  end;
end;

end.
Вложения
Тип файла: rar Project1dll.rar (2.5 Кбайт, 8 просмотров)
__________________
Пишу программы за еду.
__________________
Ответить с цитированием