I was trying a few things this morning and I found that setting the min and max of a CHARRANGE to the desired caret position and sending a EM_EXSETSEL message works for setting the caret position. For getting the caret position EM_EXGETSEL works.

I can't find any other way to do it so I assume that's the correct method.