HOME FORUMS MEMBERS RECENT POSTS LOG IN  
× Авторизация
Имя пользователя:
Пароль:
Нет аккаунта? Регистрация
Баннер 1   Баннер 2
НОВЫЕ ТОРГОВАЯ НОВОСТИ ЧАТ
loading...
Скрыть
Вернуться   ANTICHAT > ПРОГРАММИРОВАНИЕ > С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby
   
 
 
Опции темы Поиск в этой теме Опции просмотра

Добавление компонентов из dll.
  #1  
Старый 11.11.2009, 16:27
Proger10
Познающий
Регистрация: 19.12.2008
Сообщений: 78
С нами: 9154741

Репутация: 13
По умолчанию Добавление компонентов из dll.

Решил в своей программе добавить возможность подключения плагинов. Плагины решил делать dll-ками. Но множество плагинов должны будут добавлять на форму компоненты. Попытался написать в dll:
Код:
library DllPlug;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  Forms,
  StdCtrls;

{$R *.res}

procedure Exec(Form: TForm);
var
  l: TLabel;
begin
  l:=TLabel.Create(Form);
  l.Parent:=Form;
  l.Caption:='I''m adding Label from dll!';
end;

exports
  Exec;

begin
end.
, в основном приложении:
Код:
unit Unit1;

interface

uses
  Windows, Forms, StdCtrls;

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

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  Exec : procedure (Form: TForm);
  Handle : Thandle;
begin
  handle := LoadLibrary('dllplug.dll');
  if handle <> 0 then
  begin
    @Exec := GetProcAddress(handle,'Exec');
      Exec(Form1);
  end;
  FreeLibrary(handle);
end;

end.
В итоге когда жму на кнопку - Cannnot assign TFont to a TFont. Почему и как исправить??

Последний раз редактировалось Proger10; 12.11.2009 в 06:46..
 
Ответить с цитированием
 



Предыдущая тема Следующая тема
Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Требуется добавление кусочка кода в dll файл. molotovkeyt Разное - Покупка, продажа, обмен 0 11.10.2009 17:46
Возможности Динамических библиотек в Delphi dzumohu4 С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby 8 12.08.2009 17:31



Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
 


Быстрый переход




ANTICHAT ™ © 2001- Antichat Kft.