InterProcess Communication Using Visual C++ 6.0

Environment: eg VC6 WIN9x/WINNT/WIN2K

By using Visual C++ you can easily communicate with other application running on your desktop computer. You can easily do work on them. For example you can place text in a textbox, click a button and much more. In the Windows OS every object you see is a window and if you get the handle of a window, you can do many different things with it.

The key is to get the handle of the window and then make it into a CWnd Object. You can then play around with all the basic window APIs. You can even get the handle of your desktop, your Start button, and the system tray.

I will show you an example of how to get the handle of the windows Start button and enable and disable it. In the same way, you can capture any window running on the desktop.

  1. Create an MFC Dialog based Application
  2. Place two buttons in it and name them “enable” and “disable”
  3. In the “disable” button click event write the following code segment (say I call a function disable in it):
    // make them either global or class variables.
    HWND starthandle;
    CWnd StartButton;
    void disable(void)
      // Since there is only one button on the desktop, you
      // will automatically get the handle of it, otherwise
      // you will give its caption name.
      // Button is the class name of the (Button) in windows.
      // You can see the description of (FindWindowEx) in MSDN
      // for more details.
      starthandle = FindWindowEx(NULL,NULL,"Button","");
      // Now you have the button in the window form.
      // You can type cast it in either CButton or do whatever
      // you like. I will only make it invisible, so...
    void enable(void)



More by Author

Must Read