Solved

Signalling different processes

Posted on 1998-06-23
15
219 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
[X]
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
  • 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
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!

 

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
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
while loop over for loop 7 116
no14 challenge 14 73
Annoying "thing" blocks my view 4 133
Is there a simple front-end menu system. 9 123
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.

730 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