IPB
ЛогинПароль:

> ВНИМАНИЕ!

Прежде чем задать вопрос, смотрите FAQ.
Рекомендуем загрузить DRKB.

> Динамическое подключение DLL
-Екатерина-
сообщение 23.12.2007 16:13
Сообщение #1


Пионер
**

Группа: Пользователи
Сообщений: 82
Пол: Женский

Репутация: -  0  +


Пытаюсь создать библиотеку и подключить ее динамически! Уже сто раз все проверила. Не получается!!!
Вот библиотека:

library Project2;

{ 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
  SysUtils,
  Classes;

{$R *.res}
 TYPE 
    nd= ^node;
    node= record
      inf1: integer;
      inf2: string[20];
      left: nd;
      right: nd;
    end;

procedure kol_sheet(var a:nd; i, nur: integer; var k:integer);StdCall;
  begin
    if a<>nil then
    begin
      kol_sheet(a^.left, i+1, nur, k);
      if (i=nur) and (a^.left=a^.right) then inc(k);
      kol_sheet(a^.right,i+1, nur, k);
    end;
  end;
  EXPORTS KOL_SHEET ;
end.


Вот подключение и вызов:

unit Unit4;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids, ComCtrls, ExtCtrls, Menus;

type
    nd= ^node;
    node= record
      inf1: integer;
      inf2: string[20];
      left: nd;
      right: nd;
    end;
  Tkol_sheet=procedure(var a:nd; i, nur: integer; var k:integer);StdCall;


  TForm4 = class(TForm)
       procedure Button10Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form4: TForm4;
  KOL_SHEET: TKOL_SHEET;
implementation

uses Unit2, Unit3, Unit1;

{$R *.dfm}

procedure TForm4.Button10Click(Sender: TObject);
var   k,nur,H: integer;
begin
try
     K:=0;
     strtoint(edit5.Text);
     If (edit5.Text='')
     then showmessage('Введите данные!')
    else begin
        		H:=loadLibrary ( 'PROJECT2.DLL');
       		 IF H<>0
        		THEN BEGIN
               			 @KOL_SHEET := getProcAddress ( H, 'KOL_SHEET' );
                			if @KOL_SHEET <> nil then kol_sheet(root,i,nur,k);
              			 FreeLibrary(h);
            		END;
       		 Edit6.text:=inttostr(k);
      	end;
  except  showmessage('Неправильный ввод!');
end;
END;

end.


Может вы найдете ошибку... заранее спасибо!

 Оффлайн  Профиль  PM 
 К началу страницы 
+ Ответить 

Сообщений в этой теме


 Ответить  Открыть новую тему 
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 

- Текстовая версия 26.07.2025 23:07
Хостинг предоставлен компанией "Веб Сервис Центр" при поддержке компании "ДокЛаб"