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
  • Good Work

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

    Originally posted by: AZEEM SAJJAD

    I am a Software Engineer in ILM and I am novice user of Visual C. I check your work. It was a good effort and may Allah bless u and give u determination to do more and more.

    Reply
  • Loading, Please Wait ...

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

Top White Papers and Webcasts

  • Wednesday, September 24, 2014 8:00 AM - 9:00 AM PDT According to a recent Forrester Research report, many companies are choosing low-code platforms over traditional programming platforms, due to the speed with which low-code apps can be assembled and tested. With customer-facing applications on the rise, traditional programming platforms simply can't keep up with the "short schedules and rapid change cycles" required to develop these applications. Check out this upcoming webinar and join Clay Richardson from …

  • Best-in-Class organizations execute on a strategy that supports the multi-channel nature of customer requests. These leading organizations do not just open up their service infrastructures to accommodate new channels, but also empower their teams to deliver an effective and consistent experience regardless of the channel selected by the customer. This document will highlight the key business capabilities that support a Best-in-Class customer engagement strategy.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds