INTER PROCESS COMMUNICATION USING REGISTERMESSAGE and POSTMESSAGE






3.35/5 (11 votes)
Jun 22, 2006

36947

1283
IPC using custom windows messanging by win32 api
Introduction

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. 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<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 the constructor -
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
My special thanks to minja whos post is really helpful. Your comments and questions are invited.