First use
EM_GETSEL
to retrieve the character indices of the begin and end of the current selection.
For edit controls with small amounts of text you can use the window message
WM_GETTEXT
to retrieve the entire window text and select the appropriate part of it.
For multi-line edit controls with huge amounts of text, this method can be inefficient. In that case you can use
EM_GETHANDLE
to get the memory handle of the buffer that the edit control uses. Use
LocalLock
to get a memory pointer to that buffer. Then you can access that buffer directly and retrieve the select text by using the character indices that EM_GETSEL has returned.