Вниз
Скачать: CL | DM;

Возможно ли определить момент,когда мою DLL подключила программа?   Найти похожие ветки 

 
demonyator ©   (2003-04-15 00:16) [0]

<сабж> а затем выполнить какое-то действие?


 
demonyator ©   (2003-04-15 00:19) [1]

... что - то слышал про DLL_PROCESS_ATTACH...


 
einsam   (2003-04-15 00:35) [2]

Для каждой DLL существует глобальная переменная DLLProc, которая является указателем на процедуру. Ему присваивается адрес твоей процедуры входа. Процедура входа должна иметь один параметр типа DWord. Он указывает на то, какое событие произошло:
DLL_PROCESS_ATTACH - DLL загружена
DLL_PROCESS_DETACH - DLL выгружена
DLL_THREAD_ATTACH - создание нового потока процессом, к которому присоединена DLL
DLL_THREAD_DETACH - окончание работы потока.

Далее в самом проекте в begin..end. присваиваешь переменной DllProc адрес своей процедуры.

Пример из книги Пачеко/Тейксейры:

library DLLEntryLib;
uses
SysUtils,
Windows,
Dialogs,
Classes;

procedure DLLEntryPoint(dwReason: DWord);
begin
case dwReason of
DLL_PROCESS_ATTACH: ShowMessage("Attaching to process");
DLL_PROCESS_DETACH: ShowMessage("Detaching from process");
DLL_THREAD_ATTACH: MessageBeep(0);
DLL_THREAD_DETACH: MessageBeep(0);
end;
end;

begin
{ First, assign the procedure to the DLLProc variable }
DllProc := @DLLEntryPoint;
{ Now invoke the procedure to reflect that the DLL is attaching to the
process }
DLLEntryPoint(DLL_PROCESS_ATTACH);
end.


 
demonyator ©   (2003-04-16 19:05) [3]

Большое блин спасибо. :)


 
demonyator ©   (2003-04-17 22:06) [4]

БОООООЛЬШОЕ спасибо! Работает на все 100. Есть ещё один вопрос: как теперь узнать имя exe или handle программы, подключившей эту dll?


 
Digitman ©   (2003-04-18 09:59) [5]

DWORD GetModuleFileName(

HMODULE hModule, // handle to module to find filename for
LPTSTR lpFilename, // pointer to buffer for module path
DWORD nSize // size of buffer, in characters
);


Parameters

hModule

Identifies the module whose executable filename is being requested. If this parameter is NULL, GetModuleFileName returns the path for the file used to create the calling process.

lpFilename

Points to a buffer that is filled in with the path and filename of the given module.

nSize

Specifies the length, in characters, of the lpFilename buffer. If the length of the path and filename exceeds this limit, the string is truncated.

p.s.

Большое блин пожалуйста



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

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.008 c
14-50481
SH
2003-05-29 14:05
2003.06.16
Delfi и локальная сеть


7-50535
tararasyk
2003-04-12 12:01
2003.06.16
Как узнать зарегистрированный ли в системе ActiveX Automation Obj


7-50540
yura
2003-04-10 18:28
2003.06.16
Неужели никто не знает?!!!. Как в Delphi можно отключить польз..


3-50225
Ann
2003-05-26 12:48
2003.06.16
Like


4-50570
sosv
2003-04-16 10:30
2003.06.16
Установка своего курсора.




   Наверх