You can do this in two steps. First send EM_GETSEL to get the start / end indices of the selected text (0,0 if nothing is selected) Then call GetWindowText or send WM_GETTEXT to get the full text and filter the selected substring
TCHAR buffer[100];
DWORD start, end;
SendMessage(hEdit, EM_GETSEL, (WPARAM)&start, (LPARAM)&end);
GetWindowText(hEdit, buffer, 100);
TCHAR * otherBuff = new TCHAR[100];
memset(otherBuff, 0, 100 * sizeof *otherBuff);
_tcsncpy(otherBuff, buffer + start, end);
In this case, there will be an error in your code:
You dynamically allocate a buffer and return a pointer from a function
char * buffer = new char [100];
- [] . - , "". . , .
.