Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.03.06;
Скачать: CL | DM;

Вниз

DLL порядок выполнения   Найти похожие ветки 

 
Lord Zmiy ©   (2005-02-09 16:11) [0]

вопрос такой

во то что в ДЛЛ по умолчанию ставится

BEGIN

END.

если там есть какое то действо оно выполняется раньше чем функции или нет ?


 
BiN ©   (2005-02-09 16:17) [1]

Нельзя ли перефразировать вопрос. Желательно по-русски.


 
GuAV ©   (2005-02-09 16:30) [2]

Begin ... end. выполняется при загрузке библиотеки в АП процесса, т.е. когда процесс может выполнять подпрограммы из этой библиотеки она уже загружена.

Если речь идёт не об экспорированных функциях, а о функциях вообще, то функции вызываемые из initialization выполнятся раньше.


 
Lord Zmiy ©   (2005-02-09 16:33) [3]

сейчас попытаюсь :)

значит создаю длл при создание появляется стандартный текст

library Project1;

{ 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}

begin
end.

вот есть
begin
end.

вопрос такой если я к примеру сделаю так
library Project1;

{ 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;

var
i: String;

{$R *.res}

function text: PChar; stdcall;
  Begin
    Result := PChar(i);
  End;

begin
i := "ghf";
end.

у меня при использовании функции text из этой длл будет результат ghf
да или нет ???


 
Lord Zmiy ©   (2005-02-09 16:33) [4]

сейчас попытаюсь :)

значит создаю длл при создание появляется стандартный текст

library Project1;

{ 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}

begin
end.

вот есть
begin
end.

вопрос такой если я к примеру сделаю так
library Project1;

{ 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;

var
i: String;

{$R *.res}

function text: PChar; stdcall;
  Begin
    Result := PChar(i);
  End;

begin
i := "ghf";
end.

у меня при использовании функции text из этой длл будет результат ghf
да или нет ???


 
Lord Zmiy ©   (2005-02-09 16:34) [5]

Гуав спасибо понял :)


 
Reindeer Moss Eater ©   (2005-02-09 16:36) [6]

Текст между begin ...end в DLL выполняется один раз на весь процесс при загрузке библиотеки.
Если библиотеку грузят много раз или грузят из разных потоков одного процесса  - код выполняется один раз.
При вызове экспортируемых функций код между begin end не выполняется.


 
BiN ©   (2005-02-09 16:45) [7]

Lord Zmiy ©   (09.02.05 16:33) [4]

у меня при использовании функции text из этой длл будет результат ghf
да или нет ???


Да.


 
Lord Zmiy ©   (2005-02-09 16:58) [8]

Я так понял что если я допишу в эту ДЛЛку

exports Text;

тогда получу нул ??

да или нет ?


 
GuAV ©   (2005-02-09 18:28) [9]

Нет. мой русский тоже оказался не понятным.

Попробую понятнее.

begin..end выполняется при загрузке.
initialization модулей библиотеки тоже при загрузке, но раньше.

Получить адрес экспоритрованной функции можно вызвать только после загрузки.

При загрузке библиотеки управление возвращается загружающему модулю только после загрузки.

В любой из функций, которые вызываются другим модулем можно предполагать что begin..end уже выполнялся и больше выполнятся для данного процесса не будет до выгрузки dll.


 
Lord Zmiy ©   (2005-02-17 13:51) [10]

теперь понял гуав спасибо :)



Страницы: 1 вся ветка

Текущий архив: 2005.03.06;
Скачать: CL | DM;

Наверх




Память: 0.49 MB
Время: 0.029 c
3-1107868627
Ч_А_Й_Н_И_К
2005-02-08 16:17
2005.03.06
Получение имени сервера как параметр


14-1108467049
Ega23
2005-02-15 14:30
2005.03.06
Украинские народные песни


1-1108972230
DimonS
2005-02-21 10:50
2005.03.06
Вопрос по временным промежуткам


1-1108642246
Cosinus
2005-02-17 15:10
2005.03.06
Вопрос по правильному использованию ComponentCount и MDIChildCoun


14-1108116536
DelphiNew
2005-02-11 13:08
2005.03.06
Оптимизация кода