Virtual Developer Workshop: Containerized Development with Docker

Environment: VC6,Win 95/98/Me/NT/2000/XP

In this two-article series, I will show you how to retrieve conversation text from two most popular Instant Messengers (MSN and Yahoo). In the first article, we will talk about MSN Messenger. In the second article, we will discuss Yahoo Messenger. So without wasting any time, let's explore MSN Messenger now.

In MSN Messenger, the window class of the window that contains conversation text is 'RichEdit20W' for Windows NT/2K and 'RichEdit20A' for Windows 95/98. These classes support copying their content to the Clipboard by sending WM_COPY a message. Because the Clipboard is available to all the applications in Windows, if some text is copied from an application, it's available to all Windows applications. So, to retrieve text from a MSN Conversation window, simply copy the text from the MSN Conversation window to the Clipboard and paste it into your application. Simple, isn't it? But, sending the WM_COPY message to this window requires HWND of the 'RichEdit20W' Windows class window.

To get the HWND, first we need to check whether there is a MSN Conversation window open. This can be done by using the EnumWindows() API. If it's open, get its HWND and check its child windows to find a window having the window class 'RichEdit20W' or 'RichEdit20A'; this can be done by using the EnumChildWindows() API. After getting the HWND of the conversation text window, we need to send WM_COPY a message. But, sending WM_COPY a message alone will be of no use if we don't select all the text in this window, I mean simulating 'Ctrl+A'. So, in total we need to send three window messages to the conversation window. The first will select all the text in the conversation window by sending EM_SETSEL message with 0 for WPARAM and -1 for LPARAM; the second will copy the selected text in the Clipboard by sending WM_COPY a message and third will deselect the selected text by sending EM_SETSEL a message with -1 for WPARAM and 0 for the LPARAM value. This will be clear from the code snippet given below...

void CMSNChatTextDlg::OnGetnow()
  if (! EnumWindows((WNDENUMPROC )EnumWindowsProc,0))

BOOL CALLBACK CMSNChatTextDlg::EnumWindowsProc(HWND hwnd,
                                               LPARAM lParam)
  TCHAR buff[1000];
  int buffsize=100;
  if (strlen(buff)<1)
    return TRUE;

  string strTemp(buff);

  string::size_type pos=0;
  pos=strTemp.rfind("- Conversation",strTemp.length());
  if (pos!=-1)

  return TRUE;
BOOL CALLBACK CMSNChatTextDlg::ChildWndProc(HWND hwnd,
                                            LPARAM lParam)
  static int i=0;
  LPTSTR    lptstr; 
  HGLOBAL   hglb; 
  char wndowclass[CLASS_SIZE];

  if (GetClassName(hwnd,wndowclass,CLASS_SIZE)==0)
    return TRUE;

  string strTemp(wndowclass);
  if ((strTemp==string("RichEdit20W")) ||
    ::SendMessage(hwnd,EM_SETSEL,0,-1); //start selecting
    ::SendMessage(hwnd,EM_SETSEL,-1,0); //end selecting 

    if (!IsClipboardFormatAvailable(CF_TEXT))
       return TRUE;

    if (! ::OpenClipboard(NULL))
      return TRUE;

    hglb = GetClipboardData(CF_TEXT);
    if (hglb != NULL)
      lptstr = (LPTSTR)GlobalLock(hglb);

      return FALSE;
  return TRUE;

This gives us the opportunity to make some fantastic SPYING applications that can e-mail MSN conversations of someone to you or whatever you can think of!

In my next article, we will discuss how the same thing can be done with Yahoo Messenger. Remember, WM_COPY messages do not work in Yahoo. We need to put in some extra effort to accomplish this.


Download demo project - 4.50 Kb
Download source - 28.3 Kb


  • need help.

    Posted by shrirangps on 02/10/2005 08:23am

    i want to check the online status for any given msn user.. the contact may not be in my contact list.. can anyone help me doing it! thanks and regards.

  • retrieving messages???

    Posted by Legacy on 02/13/2004 08:00am

    Originally posted by: Jim

    I want to retrive a conversation that I wrote with a friend on msn messenger. This conversation took place a few days ago. where would I look to find this conversation or how can I retrieve it? not much of a techy and i didn't have any of the above stuff on my puter. any help would be great.

    Many thanks


  • MSN 6.0?

    Posted by Legacy on 09/25/2003 07:00am

    Originally posted by: Umashankar

    Does anybody know how to get chat window text in MSN 6.0?

  • !!!!msn 6 its DirectUIHWND ...not these."RichEdit20W.."...

    Posted by Legacy on 08/26/2003 07:00am

    Originally posted by: sibilsalim

    msn 6 its DirectUIHWND ...not these-->"RichEdit20W.."..
    even after changing to this new class ..its not working help ..me
    help me at sibilsalim@operamail.com

    • How to send out message from my program on MSN6.0?

      Posted by zhgfhz on 07/17/2004 01:54am

      In MSN5.0, I can send out message by setwindowtext and click button. But on MSN6.0, how to do it? Since it is DirectUIHWND. Very helpful to me. Thanks first. Juck

  • C++ Code under Linux?

    Posted by Legacy on 06/15/2003 07:00am

    Originally posted by: toby

    Has anyone every tried using it with Linux?

  • Separate files

    Posted by Legacy on 05/27/2003 07:00am

    Originally posted by: AlejoCL

    I'd like to save the conversations into a file. One file per conversation. Also, I'd like to "get" the mail (at least) of the other part.

    Thank you for your help.


  • Does this really work..?

    Posted by Legacy on 04/29/2003 07:00am

    Originally posted by: Gizzy

    I am a little confusd. Now, Does this enable you to spy on someone else's conversation with a third person...? As if you are physically not there, but still able to read the converstaion between 2 people...?

  • cont retrieve saved msn conversations

    Posted by Legacy on 03/23/2003 08:00am

    Originally posted by: courtney

    i had a conversation with a friend of mine and my parents would like to see it. all our msn conversations are saved on our computer but we dont know where to look if anyone cant help pleeze its very important!!!


  • need help

    Posted by Legacy on 02/26/2003 08:00am

    Originally posted by: ranvijay

    i need ur help in my application.i am developing yahoo messenger like application and i'm using rtf control for giving text formatting capability.but how could i maintain text format of messages on destination side.
    please help me.

  • need help with spying yahoo messeger

    Posted by Legacy on 01/24/2003 08:00am

    Originally posted by: tik

    I like to know if there is way of spying someone and monitor who are they chatting with?

    I do'nt have access to there computer, can't install a spying program... Is ther any other way arround it???
    please help!!!!

  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date