'******************************************************************************************** 'Documentation to the Standard DLL "dscwpmsg.dll" (c) 2001 by J. Thuemmler, Delphin Software '******************************************************************************************** '++++++++++++++++++++++ This DLL is Freeware and provided "As Is" +++++++++++++++++++++++++ '******************************************************************************************** Purpose of the DLL: Installing a system wide or thread related WH_CALLWNDPROC and/or WH_GETMESSAGE Hook For using the DLL, put the file into your program/project folder, not into the system folder. '-------------------------------------------------------------------------------------------- How it works: When you call the function "SetCWPMSGHook()", either a thread related or system wide Hook of the types "WH_CALLWNDPROC" and/or "WH_GETMESSAGE" will be installed to watch for messages. If the Hook function(s) record(s) a message, a copy of the message will be sent by the DLL calling one or two public function(s) in your application of the following prototype: Public Function Callback& (ByVal hwnd&, ByVal msg&, ByVal wParam&, ByVal lParam&) The passed parameters are a copy of the original message. The WH_CALLWNDPROC Hook monitores messages which are sent using "SendMessage()" to the window "hwnd"; the WH_GETMESSAGE Hook monitores messages which are polled from the message queue of the app using "GetMessage()" or "PeakMessage()". You can define up to 10 global messages to be discarded when they appear anywhere in the scope of the Hook(s), using the function "SetGlobalMessage&()". You can define up to 10 window handles and for each of these handles up to 10 messages to be discarded when they appear, using the functions "SetMessageWindow&()" and "SetWindowMessage&()". In principle you can use the DLL to hook your own app, but this task should better be done using your own call of "SetWindowsHookEx()" and providing your own Hook function(s), because in this case you'll get the original messages and will be able to modify t !!! WARNING !!! Using this DLL in a wrong way may lead to a crash. You should be very familiar with the Windows API when you use these Hooks. Although the function calls are only copies of the original messages, you should avoid time consuming code in the callback functions, especially when you are using system wide hooks. For details about the Hooks, the messages and the meaning of wParam and lParam see SDK. !!! USING THE DLL IS AT YOUR OWN RISK !!! '******************************************************************************************** Function declaration: Declare Function SetCWPMSGHook& Lib "dscwpmsg" (ByVal Hook&, ByVal AdrCWP&, ByVal AdrMSG&) '-------------------------------------------------------------------------------------------- Parameter: Hook& (-1, 0, hwnd&) When Hook = -1, (a) systemwide Hook(s) will be installed, when Hook = hwnd&, the Hook(s) will be installed on the thread, the window hwnd belongs to, when Hook = 0, the Hook(s) will be released. When you use a system wide hook, messages of your own thread will be not considered to avoid recoursive calls. AdrCWP& Address of the Callback Function in your app, which shall be called to receive the CWP message copies, passed using "AddressOf CWPFunction". The Callback Function must be placed in a standard module and match the following type: Public Function CWPFunction& (ByVal hwnd&, ByVal msg&, ByVal wParam&, ByVal lParam&) NOTE: If you don't need this type of Hook, set "AdrCWP&" to zero (0). Then you don't need the according callback function. If you need this Hook for discarding messages, but without any callback, set "AdrCWP&" to one (1). Then you also don't need the according callback function. AdrMSG& Address of the Callback Function in your app, which shall be called to receive the MSG message copies, passed using "AddressOf MSGFunction". The Callback Function must be placed in a standard module and match the following type: Public Function MSGFunction& (ByVal hwnd&, ByVal msg&, ByVal wParam&, ByVal lParam&) NOTE: If you don't need this type of Hook, set "AdrMSG&" to zero (0). Then you don't need the according callback function. If you need this Hook for discarding messages, but without any callback, set "AdrMSG&" to one (1). Then you also don't need the according callback function. '-------------------------------------------------------------------------------------------- Return Value: 2, if both of the Hooks were installed rsp. released successfully, 1, if one of the Hooks was installed rsp. released successfully, 0 (Zero) otherwise. '******************************************************************************************** Function declaration: Declare Function SetGlobalMessage& Lib "dscwpmsg" (ByVal Msg&, ByVal wParam&) '-------------------------------------------------------------------------------------------- Parameter: Msg& The message which should be discarded in the scope of the Hook(s) wParam& Any meaningful value for the message (e.g. WM_SYSCOMMAND, SC_CLOSE) or 0 (zero). '-------------------------------------------------------------------------------------------- Return Value: 1 (True), if the number of messages <= 10, otherwise 0 (False). '******************************************************************************************** Function declaration: Declare Function SetMessageWindow& Lib "dscwpmsg" (ByVal hwnd&) '-------------------------------------------------------------------------------------------- Parameter: hwnd& A window handle to define discarding messages for. '-------------------------------------------------------------------------------------------- Return Value: An Index from 0 to 9, when the number of windows <= 10, otherwise -1. '******************************************************************************************** Function declaration: Declare Function SetWindowMessage& Lib "dscwpmsg" (ByVal Index&, ByVal messg&, ByVal wParam&) '-------------------------------------------------------------------------------------------- Parameter: Index& The return value of the function "SetMessageWindow&()" which identifies the window. messg& The message which should be discarded for the specific window. wParam& Any meaningful value for the message (e.g. WM_SYSCOMMAND, SC_CLOSE) or 0 (zero). '-------------------------------------------------------------------------------------------- Return Value: 1 (True), if the number of messages for the window <= 10, otherwise 0 (False). '******************************************************************************************** Delphin Software Mail: delphinsoft@gmx.de Phone: +49 07251 18671 Fax: +49 07251 989773 '********************************************************************************************