[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

Signalling different processes

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
akhila
Asked:
akhila
  • 7
  • 5
  • 2
  • +1
1 Solution
 
chensuCommented:
No. You can either send window messages if there are windows or use the synchronization objects, such as event objects.
0
 
akhilaAuthor Commented:
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
 
chensuCommented:
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
Industry Leaders: 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!

 
akhilaAuthor Commented:
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
 
chensuCommented:
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
 
akhilaAuthor Commented:
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
 
chensuCommented:
I am sorry that I don't have enough time to write it.
0
 
tma050898Commented:
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
 
akhilaAuthor Commented:
Tma,
   Ok..I have increased the points to 100. Can you help atleast now?
0
 
tma050898Commented:
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
 
akhilaAuthor Commented:
Thank U tom.

0
 
chensuCommented:
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
 
akhilaAuthor Commented:
Thank U Chensu
0
 
duneramCommented:
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
 
akhilaAuthor Commented:
Duneram,
  Thank you very much. I'll definitely try it.
-AKhila
0

Featured Post

Industry Leaders: 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!

  • 7
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now