how to pass data from between process in vb.net 2008

  • Thread starter Thread starter golden_au
  • Start date Start date
G

golden_au

Hi,

I need to have 2 processes, one is monitorring the parallel port status in
every 30 sec at the background and then send the status to the listbox of
another window, I am new to vb.net, many thanks for any advice.
 
Why do you need two processes? With a single process, you could use a timer
set to tick every 30s and simply update the port status display each tick.

If you can use threads instead of separate processes, then that would be the
next best option. See:
http://support.microsoft.com/kb/316422
(especially the simpler examples)

If you really must use separate processes then you will need some
interprocess communication, such as a named pipe. This is starting to get
complicated. See
http://support.microsoft.com/kb/871044
 
Thanks for your advise, on the other hand I found sendmessage() funtion can
do the job:

++++++++++++++++++++++++++++++++++++++++++++++++++++
Option Strict Off
Option Explicit On

Module InpOut32_Declarations 'Inp and Out declarations for port I/O using
inpout32.dll.
Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" (ByVal
PortAddress As Short) As Short
Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal
PortAddress As Short, ByVal Value As Short)
End Module
Friend Class frmSend
Inherits System.Windows.Forms.Form
Const cHIDDEN_WINDOW_TITLE As String = "Main Control Panel - Robot
Control Centre"
Const WM_SETTEXT As Integer = &HC

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef
lParam As Integer) As Integer
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA"
(ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal
lpsz2 As String) As Integer


Private Sub frmSend_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim FHandle As Integer
Dim currentstatus As String
Dim THandle As Integer
FHandle = FindWindow(vbNullString, cHIDDEN_WINDOW_TITLE)
THandle = FindWindowEx(FHandle, 0, vbNullString, vbNullString)
currentstatus = Inp(&H379S)
MsgBox(currentstatus)
While FHandle <> 0
SendMessage(THandle, WM_SETTEXT, 0, currentstatus)
System.Threading.Thread.Sleep(500)
FHandle = FindWindow(vbNullString, cHIDDEN_WINDOW_TITLE)
'MsgBox(FHandle)
End While
Me.Close()
End Sub
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
the adove code can send a integer from on window to another, but the problem
is the integer send from sender can not display properly in the textbox of
receiver, for example, I send 123, it display {, if sent other integer, it
may display some unknow contents, do you have any idea?
 
Back
Top