Link to home
Start Free TrialLog in
Avatar of sundayboys
sundayboys

asked on

how to read exe's dbgrid content in DLL???

i have a exe writen by delphi(no sourcecode), the exe load a DLL, i have the DLL sourcecode,but exe's Application not pass to DLL, so i cannt read any class from exe mainform, i want read dbgrid content from exe mainform in DLL,how to resolve it???
Avatar of ginsonic
ginsonic
Flag of Romania image

Can't! The exe must send the values to dll to can use inside dll.
Avatar of sundayboys
sundayboys

ASKER

no way???sigh...
Avatar of Wim ten Brink
It can be done but it requires a lot of knowledge of the Windows API and the Delphi VCL. You would have to find the window handle of the form that contains the grid, find the grid on this form, get the exact address of the grid itself and then use a typecast of the TDBGrid (if that is used) around the pointer that is pointing to the grid. You would have to be very aware of the memory manager in the main executable and see if you can connect to it too. (The use of Sharemem is useless since the EXE is probably NOT using it.) If you can't hook into the memory management of the main executable then you cannot use any strings in your communication between DLL and EXE since this would cause serious memory leaks and will crash the application.

I think it's easier to just rewrite that executable or just buy the source of it if someone made it for you. It might take too much time just to get it working correctly.
i want use ReadProcessMemory to find the content of grid,is it a good idea?
Use ReadProcessMemory if you want to read some memory area from another process. Since the DLL is injected in the same address space as the executable, you don't need it.
And I do consider this a very complex solution do do, what exactly? That application must be reading it's data from some database so why don't you read it from the same database?
Hi,

Once you've found the window handle, you should be able to send it the
correct control messages( there should be a bunch for DBGrid I suppose ).

why don't you look for that?

HTH,

Andrew
yeah, i can find DBGrid handle,but i dont know any control message about DBGrid,could someone helps me???

i dont know which database that exe used, username and password nobody knows :-(
Uhm... you might want to look at the Messages unit and the DBCtrls one to see if you can find any message.

Cheers,

Andrew
ASKER CERTIFIED SOLUTION
Avatar of Wim ten Brink
Wim ten Brink
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial