Здравствуйте, spino, Вы писали:
S>может кто сталкивался с подобной проблемой?
Да, тебе надо выделить память в адресном пространстве
того процесса. Передать указатель на
ту память и потом уже оттуда читать.
Вобщем вот так я читал выделеие в чужом RichEdit — надеюсь поможет.
// Local variables
C_RichEdit CRichEdit(hWndFocus);
C_Process CProcess;
LPVOID lpMemoryExternal;
LPVOID lpMemoryInternal;
DWORD processID;
DWORD start;
DWORD end;
// Code
CRichEdit.sm_getsel(&start, &end);
end -= start - 1;
CString.Create(CRichEdit.sm_gettextlength() + 1);
GetWindowThreadProcessId(hWndFocus, &processID);
CProcess.Open(PROCESS_VM_OPERATION|PROCESS_VM_READ, FALSE, processID);
if (IsWindowUnicode(hWndFocus) != FALSE)
{
lpMemoryExternal = VirtualAllocEx(CProcess, NULL, sizeof(WCHAR) * end, MEM_COMMIT, PAGE_READWRITE);
lpMemoryInternal = memAlloc(sizeof(WCHAR)*end);
CRichEdit.sm_getseltext((LPTSTR)lpMemoryExternal);
CProcess.ReadMemory(lpMemoryExternal, lpMemoryInternal, sizeof(WCHAR) * end, &start);
if (start != end * sizeof(WCHAR))
{
VirtualFree(lpMemoryExternal, 0, MEM_RELEASE);
memFree(lpMemoryInternal);
return METHOD_UNKNOWN;
}
VirtualFree(lpMemoryExternal, 0, MEM_RELEASE);
CString.Create((LPWSTR)lpMemoryInternal);
memFree(lpMemoryInternal);
}
else
{
lpMemoryExternal = VirtualAllocEx(CProcess, NULL, sizeof(CHAR)*end, MEM_COMMIT, PAGE_READWRITE);
lpMemoryInternal = memAlloc(sizeof(CHAR)*end);
CRichEdit.sm_getseltext((LPTSTR)lpMemoryExternal);
CProcess.ReadMemory(lpMemoryExternal, lpMemoryInternal, sizeof(CHAR) * end, &start);
if (start != end * sizeof(CHAR))
{
VirtualFree(lpMemoryExternal, 0, MEM_RELEASE);
memFree(lpMemoryInternal);
return METHOD_UNKNOWN;
}
VirtualFree(lpMemoryExternal, 0, MEM_RELEASE);
CString.Create((LPSTR)lpMemoryInternal);
memFree(lpMemoryInternal);
}
return METHOD_EDIT;