i wrote this little Win32 Console program to show you how. it is designed for Yahoo Messenger, since i don't use MSN Messenger. it disables the Search button.
when you open this program it searches for Yahoo Messenger. if its not open or the title of the window is different than "Yahoo Messenger". you get an error. if it is open it finds the Search button. and disables it.
i don't have much time. so repost if you dont understand.
BOOL CALLBACK EnumProc(HWND hwnd, LPARAM lParam)
GetWindowText(hwnd, wndtitle, 254);
hYahoo = FindWindow(0, "Yahoo! Messenger");
if(hYahoo == NULL)
cout<<"Yahoo! Messenger is not open or has a different title";
EnumChildWindows(hYahoo, EnumProc, 0);