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","");
      StartButton.m_hWnd=starthandle;
    
      // 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...
    
      StartButton.ShowWindow(FALSE); 
    }
    
    void enable(void)
    {
      StartButton.ShowWindow(TRUE);
    }

    Downloads

    None


Comments

  • how about the start menu ?

    Posted by Legacy on 02/14/2003 12:00am

    Originally posted by: soul

    anyone knows how to access the start menu ?
    i would need to count items, find position and get strings from the start menu ...

    thx in advance for any tips/code

    Reply
  • doesn't work

    Posted by Legacy on 11/15/2002 12:00am

    Originally posted by: Qian

    doensdjfdlsajf
    

    Reply
  • click a button and much more...You think much more? slow down

    Posted by Legacy on 10/23/2002 12:00am

    Originally posted by: sasha

    It looks an impressive from first glance, but in fact, you can do very little with that HWND you get. To be more presize only those things which are passed through stack without addressing memory. e.g. you can't read a content of list/tree control, all this because this assumes getting into address space of another process, which is a bit more complicated.
    That is all for now

    Reply
  • Killing open applications on the desktop

    Posted by Legacy on 10/17/2002 12:00am

    Originally posted by: Ato Koomson

    Hi, I really need help on this.

    I am writing an application within which I have to close all other open applications on the desktop when it is exiting.

    Can anyone help me out here. I am developing in VC++.

    Thanks in advance.

    Reply
  • Accessing Accelerators

    Posted by Legacy on 04/13/2002 12:00am

    Originally posted by: Graham Child

    I needed to access the accelerators for mspaint and came up with this:-
    
    

    57642 = select all for mspaint ctrl a
    57634 = copy
    Numbers obtained from spy Wid57642 etc

    code

    starthandle = FindWindowEx(0,0,"MSPaintApp",NULL);


    if(starthandle)
    {
    StartButton.m_hWnd=starthandle;
    StartButton.PostMessage(WM_COMMAND,0xe12a,1);//57642
    StartButton.PostMessage(WM_COMMAND,0xe122,1);//57634
    }
    CloseHandle(starthandle);
    CloseHandle(StartButton);

    Regards Graham


    Reply
  • can't Click on Test Page OK Button

    Posted by Legacy on 03/11/2002 12:00am

    Originally posted by: Naveen Maheshwari

    Hi!
    
    I found the Idea given as very interesting...and helpful ...but stuck up in a problem ..what I am trying to do is to write a application that opens up properties of any printer and fire test page on Windows 2000 machine.
    Using the given Technique I could fire the test page but I am unable to click on OK button on the confirmayion dialog box which comes up just after Print Test Page "test page printed Properly"...
    To open printer properties I am using

    CreateProcess() with command line as
    rundll32 printui.dll,PrintUIEntry /p /n printername

    This opens up propertypage and I am able to print test page but after that my application is set as not responding till manually click on OK button.
    code written for firing test page is

    TestPage = FindWindowEx(NULL,NULL,"#32770",NULL);
    TestPage = FindWindowEx(TestPage,NULL,NULL,"General");
    TestPage = FindWindowEx(TestPage,NULL,"Button","Print &Test Page");
    if (TestPage)
    {

    bnTestPage.m_hWnd=TestPage;
    bnTestPage.SendMessage(BM_CLICK,NULL,NULL);
    }


    pls Help.

    Reply
  • Inter-process

    Posted by Legacy on 02/01/2002 12:00am

    Originally posted by: Maha

    Hi,
    when i try to run the code the assertion error is coming. it seems like we've to give the start button caption in the last argument. mine is NT Workstation.Is it a problem with N? I want this in a different way like.. I want to send text from my application to a text box which is appeared in the browser. How do i do it? Plz help me if u know

    Thanx in advance

    maha

    Reply
  • Useful tips to me. Thanks a lot!

    Posted by Legacy on 11/28/2001 12:00am

    Originally posted by: leo

    Reply
  • Posted by Legacy on 11/28/2001 12:00am

    Originally posted by: leo

    Useful tips to me. Thanks a lot!

    Reply
  • Code Modification

    Posted by Legacy on 11/27/2001 12:00am

    Originally posted by: Umer Naseer

    starthandle = FindWindowEx(0, 0, "Shell_TrayWnd", NULL);
    
    starthandle = FindWindowEx(starthandle, 0, "Button", NULL);
    StartButton.m_hWnd=starthandle;


    Replace the first two lines of code by these lines, because
    first we need to get the handle of the taskbar and then we
    would be able to get the refrence of the button, because in windows architecture taskbar serves as the parent of the start button.

    Reply
  • Loading, Please Wait ...

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

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Businesses are moving more and more of their customer transactions to the web. Security is understandably a top concern as online transactions increase, so it is important to make sure your electronic signature provider meets the highest security standards. That means more than simply passing a security audit or obtaining a certification. This white paper provides recommendations for taking a broader view of e-signature security, and answers key questions that help identify the security requirements against …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds