Antonino,
FWH REGetOleInterface() basically does this (what you already posted in the provided example):
SendMessage( hEdit, EM_GETOLEINTERFACE, 0, ( LPARAM ) &tr_code );
IMO, in the example that you have posted you have everything you need to implement it