0

i need to use EM_GETTEXTRANGE with WriteProcessMemory and ReadProcessMemory in c#

i already get the start position and the end position of word but i can't use this EM_GETTEXTRANGE to get the word

any body help me

bebo
  • 67
  • 1
  • 10

1 Answers1

0

You need a bunch more pinvoke. First off, you need to allocate memory in the target process so it can read and write the TEXTRANGE structure value. That requires OpenProcess and VirtualAllocEx. Now you need to initialize the structure, first order of business is to get memory for the lpstrText member. VirtualAllocEx again to allocate a buffer large enough to store the string, WriteProcessMemory to initialize the structure.

Now your ready to call SendMessage. ReadProcessMemory to read the lpstrText back. Cleanup with two times VirtualFreeEx and CloseHandle to close the process handle.

About a hundred ways to shoot the foot. This is popular kind of code at codeproject.com, I know it is there but their search is completely borked as of late. Good luck!

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • yes i used this way i edit my Question please try to help me i tack two day to do this what the wrong in my code – bebo Dec 25 '10 at 22:01