Communicating between programs

Posted on 2003-03-12
Medium Priority
Last Modified: 2010-04-17
I have written a program in Visual c++.  I wanted the program to only be able to run once.(if the desktop icon was clicked while it was running it was just restored)  I did this by:

     HWND AlreadyThere = FindWindow(NULL,"My Main Windows Name")
     If(AlreadyThere != 0)
          ShowWindow(AlreadyThere, SW_RESTORE);
          return 0;

But now I want to take it a step further.  Instead of calling a ShowWindow(AlreadyThere, SW_RESTORE); I want to send a Message to AlreadyThere so I can Have my Program do some extra stuff when it was restored by way of double clicking the desktop icon

Any help
Question by:MightyK
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

Nosfedra earned 80 total points
ID: 8120015
You can send a custom message to your function.
define your own message with


And when you find there is an instance of your program already running (by the way, you might want to take a look at MSDN - WinMain; look at hPrevInstance paramete, you'll find there how you find out if an instance of your program is already running) you just do a
SendMessage(your_Wnd_handle,WM_DO_COOL_TRICKS,0,0), if you won't pass any params in WParam and LPARAM and then, in the window receiving the message, treat the message in the big case structure of your window callback function.

Expert Comment

ID: 9447192
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Starting up a Project

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question