Solved

Signalling different processes

Posted on 1998-06-23
15
211 Views
Last Modified: 2013-11-20
Can i  use the process-id of a process to send a signal from another process using the process-id? If this is not possible can u please suggest one way of sending signals to different processes?
0
Comment
Question by:akhila
  • 7
  • 5
  • 2
  • +1
15 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1318313
No. You can either send window messages if there are windows or use the synchronization objects, such as event objects.
0
 

Author Comment

by:akhila
ID: 1318314
Can u please give me the code segment of 2 separate applications trying to synchronize using the CEvent object? I am not able to understand where the actual connection between the 2 applications is created and how.
Thank U

0
 
LVL 23

Expert Comment

by:chensu
ID: 1318315
Look into the MFC Sample MTGDI. It is a multithread program. Two threads are similar to two applications except that you should give the event object a name so that another application can refer to it.

CEvent( BOOL bInitiallyOwn = FALSE, BOOL bManualReset = FALSE, LPCTSTR lpszName = NULL, LPSECURITY_ATTRIBUTES lpsaAttribute = NULL );

lpszName   Name of the CEvent object. Must be supplied if the object will be used across process boundaries. If the name matches an existing event, the constructor builds a new CEvent object which references the event of that name. If the name matches an existing synchronization object that is not an event, the construction will fail. If NULL, the name will be null.

0
 

Author Comment

by:akhila
ID: 1318316
U have given the same text from the book!! Now one thing still i am not able to understand is that from which appliction I will be calling the CEvent constructor? SHould I have it both the applns. with the same name  or how should I proceed? I am notr able to understand from that example.

0
 
LVL 23

Expert Comment

by:chensu
ID: 1318317
You should construct the CEvent objects in both the applications with the same name. When it is constructed in this way, a new event object will be created if the name does not exist yet. Otherwise, if the name exists due to one of the applications has created it, the event object will reference the event of that name.
0
 

Author Comment

by:akhila
ID: 1318318
Sorry for disturbing u again!! If u dont mind please can u give a simple code construct of 2 applications using and accessing CEvent?
Thank U very much

0
 
LVL 23

Expert Comment

by:chensu
ID: 1318319
I am sorry that I don't have enough time to write it.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Expert Comment

by:tma050898
ID: 1318320
akhila,

A little friendly advice. I think you're being a little unrealistic in offering 10 points and expecting verbose, in depth answers. I think (considering the points) chensu has given very good advice in answering your question.

Don't get me wrong. we all frequently answer "low rent" questions(20-50 points). However, most developers don't have the time or motivation to write someone else's code when the person requesting the help thinks the help merits so little.

Just my 0.02,
Tom

0
 

Author Comment

by:akhila
ID: 1318321
Tma,
   Ok..I have increased the points to 100. Can you help atleast now?
0
 
LVL 3

Expert Comment

by:tma050898
ID: 1318322
I sincerely hope that you don't feel upset about my remarks. My only intention was to aid you in getting your question answered to your satisfaction. Since you have waited for an answer for about 3 weeks, I made the suggestion of upping the points in order to encourage more responses.

Having said that, honor dictates that I should give chensu first crack at this since you were working with him. If he passes, then I'll throw together a simple example for you. Ok?

Tom

0
 

Author Comment

by:akhila
ID: 1318323
Thank U tom.

0
 
LVL 23

Expert Comment

by:chensu
ID: 1318324
Hi tma,

Your turn.

akhila,

Don't misunderstand. I don't have enough time. If I had a ready example, I would have provided.
0
 

Author Comment

by:akhila
ID: 1318325
Thank U Chensu
0
 
LVL 2

Accepted Solution

by:
duneram earned 100 total points
ID: 1318326
Here is a method I have used of sending signals to other processes on the system.  Its very unorthodox, but it works and it gets you into the memory space of the other process (sans source code) if that is of interest to you.

1)  Write a function in a DLL that will called whenever a specific Registered Windows message comes thru.   The purpose of your function would be defined by you.  You could use mapped memory or whatever you want if you want to do synchronization techniques.

2) In the same DLL write a windows proc hook with handling for your special registered windows message.

3) Install a system wide hook, so your DLL is mapped into the other process spaces across your system.

4) Register your own windows message (use the one your proc is expecting to receive). and have each instance of the hook proc (in the dll) register the message' to get its special windows assigned id.

Now when ever you want the other processes in the system to listen to what you want to do, you just either post a message to the given application, or across the whole system.


And thats about it....


0
 

Author Comment

by:akhila
ID: 1318327
Duneram,
  Thank you very much. I'll definitely try it.
-AKhila
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now