Click here to Skip to main content
15,885,782 members
Articles / Programming Languages / Visual Basic
Article

INTER PROCESS COMMUNICATION USING REGISTERMESSAGE and POSTMESSAGE

Rate me:
Please Sign up or sign in to vote.
3.35/5 (11 votes)
22 Jun 2006 36.4K   1.3K   12   4
IPC using custom windows messanging by win32 api

Introduction


Image 1

Hi actually i'm not that professional to submit a material, but as our need arises we
do search for program snaps. I have used many programs and studied them.This program 
basically is the small part of what i was required to do.But i found this as a small 
and easy programm to start with.

 This is actually all about windows messanging. While performing a task there arose a 
 need to develop the application that interact with the other application. This is the
 extract that you'd like to see.

<FONT COLOR=black>
the easiest steps for interprocess communication are:--

application one:-

1) declare similar message and register it
2) make an identification of it self so that other application can search that.
using...
        Dim Params As CreateParams = New CreateParams
        Params.Caption = <caption goes here>
        Me.CreateHandle(Params)
3) use wndproc method to listen pre-registered windows message and act accordingly

application two:-

1) declare windows message.
2) Register windows message
3) find window (params used here) to which message are to be issued(actually to windows 

message queue)
4) post message using postmessage windows command
</FONT>
<P>
<CODE>
the basic windows api used -

    Private Declare Function RegisterWindowMessage Lib "user32" Alias _       "RegisterWindowMessageA" _
(ByVal lpString As String) As IntPtr
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As IntPtr, ByVal wMsg As IntPtr, ByVal wParam As Integer, _
ByVal lParam As Integer) As IntPtr
</CODE>

the constructor -
<CODE>
    Public Sub New()
        '''''Creating Window based on globally known name, and create handle
        '''''so we can start listening to Window Messages.
        Dim Params As CreateParams = New CreateParams
        Params.Caption = GLOBAL_IDENTITY_ONE
        Me.CreateHandle(Params)
    End Sub
</CODE>




My special thanks to  minja whos post is really helpful.
Your comments and questions are invited.
</P>




</P>

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Engineer
India India
Kedar Vaijanapurkar
theghost_k8@yahoo.com

Comments and Discussions

 
Generalhelpful Pin
Jarw AI19-Oct-06 4:56
Jarw AI19-Oct-06 4:56 
GeneralRe: helpful Pin
K edar V19-Oct-06 19:26
K edar V19-Oct-06 19:26 
Gud programers alway stuck @ right place.. search for right thing.. and got the right Solution... kidding.. Wink | ;)

"You can do any thing you set to your mind" - theGhost_k8

Generallooks Pin
chix_v29-Jun-06 1:08
chix_v29-Jun-06 1:08 
GeneralRe: looks Pin
K edar V4-Jul-06 19:47
K edar V4-Jul-06 19:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.