DLL code
# pragma option - zRSHSEG
# pragma option - zTSHCLASS
#include
#include
#include
#include
#include
#include
#include
#include
#include
# pragma hdrstop
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//Important note about DLL memory management the when your DLL USES the
//the static version of the RunTime Library:
//
//If your DLL exports any functions provides that pass the String objects (or user-defined structs/
//classes containing nested Strings) as the parameter or the function results,
//you will need to add the library MEMMGR. LIB to both the DLL project and
//any other projects that use the DLL, You will also need to use MEMMGR. LIB
//if any other projects which use the DLL will be performing new or delete
//operations on any non - TObject - derived classes which are exported from the
//DLL. Adding MEMMGR. LIB to your project will change the DLL and its calling
//EXE 's to use the BORLNDMM. DLL as their memory manager. In these cases,
//the file BORLNDMM. DLL should be deployed along with your DLL.
//
//To get the using BORLNDMM. DLL, pass the string information using "char *" or
//ShortString parameters.
//
//If your DLL USES the dynamic version of the RTL, do not need to
//explicitly add MEMMGR. LIB as this will be done implicitly for you
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# pragma argsused
Extern "C" __declspec (dllexport) __stdcall BOOL InstallHook () (HWND AHandle, int AParam, HINSTANCE g_hinstDll);
HWND ghWnd=NULL;
HHOOK rHook;
The HWND rHandle;
int count=0;
LPDWORD fegdds;
String ControlAtomString;
TAtom ControlAtom;
DWORD RM_GetObjectInstance;
TWinControl * FindControl1 (HWND Handle);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
TWinControl * FindControl1 (HWND Handle)
{
DWORD OwningProcess;
If (Handle!=0 & amp; & GetWindowThreadProcessId (Handle, & amp; OwningProcess)!=0 & amp; & OwningProcess==GetCurrentProcessId ())
{
If (GlobalFindAtom (ControlAtomString c_str ())==ControlAtom)
{
Return (TWinControl *) GetProp (Handle, MakeIntAtom (ControlAtom));
}
The else
{
Return (TWinControl *) SendMessage (Handle, RM_GetObjectInstance, 0, 0);
}
}
return NULL;
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
LRESULT a CALLBACK hooks (int code, WPARAM WPARAM, LPARAM LPARAM)
{
If (wParam==WM_LBUTTONUP & amp; & The count==0)
{
AnsiString ss="link";
HWND hEdit=FindWindowEx (ghWnd, NULL, "TEdit", NULL);
SendMessage (hEdit, WM_SETTEXT, 0, (LPARAM) (ss. C_str ()));
TWinControl * vWinControl;
int i,j;
AnsiString S tmpGridStr;
TDataSet * DataSet;
If (ControlAtomString. IsEmpty ())
{
//ControlAtomString=Format (" ControlOfs %. 8 x %. 8 x ", ARRAYOFCONST (((WORD) GetWindowLong (VSnifferInfo - & gt; RHandle GWL_HINSTANCE), (WORD) GetWindowThreadProcessId (VSnifferInfo - & gt; RHandle OUT fegdds))));
ControlAtomString=Format (" ControlOfs %. 8 x %. 8 x ", ARRAYOFCONST (((WORD) GetWindowLong (rHandle, GWL_HINSTANCE), (WORD) GetWindowThreadProcessId (rHandle, OUT fegdds))));
//ControlAtomString=Format (" ControlOfs %. 8 x %. 8 x ", ARRAYOFCONST (((WORD) GetModuleHandle (NULL), (WORD) GetCurrentThreadId)));
ControlAtom=GlobalAddAtom (ControlAtomString c_str ());
RM_GetObjectInstance=RegisterWindowMessage (ControlAtomString c_str ());
}
VWinControl=FindControl1 (rHandle);
If (vWinControl)
{
for(i=0; i{
If (AnsiString (vWinControl - & gt; The Components [I] - & gt; The ClassName ()). AnsiCompare (" TDBGrid ")==0)
{
TmpGridStr="";
The DataSet=TDBGrid (vWinControl - & gt; The Components [I]). The DataSource - & gt; The DataSet.
TmpGridStr=DataSet - & gt; Fields - & gt; FieldByNumber (0) - & gt; AsString + DataSet - & gt; Fields - & gt; FieldByNumber (1) - & gt; AsString;
SendMessage (hEdit, WM_SETTEXT, 0, (LPARAM) (tmpGridStr. C_str ()));
}
The else
{
SendMessage (hEdit, WM_SETTEXT, 0, (LPARAM) "can't find the dbgrid");
}
}
}
The else
{
SendMessage (hEdit, WM_SETTEXT, 0, (LPARAM) "can't find the form");
}
count++;
}
Return (CallNextHookEx (rHook, code, wParam, lParam));
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Extern "C" __declspec (dllexport) __stdcall
Void SetWindowHandle (HWND ahWnd)
{
GhWnd=ahWnd;
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull