Click here to Skip to main content
16,006,440 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: our team creating the hotel management project we want concepts of what accounts maintain hotel management Pin
Dave Kreskowiak10-Jul-06 5:14
mveDave Kreskowiak10-Jul-06 5:14 
Questionabout date format [modified] Pin
charan049-Jul-06 23:36
charan049-Jul-06 23:36 
AnswerRe: about date format Pin
Rizwan Bashir10-Jul-06 2:41
Rizwan Bashir10-Jul-06 2:41 
GeneralRe: about date format Pin
charan0410-Jul-06 16:37
charan0410-Jul-06 16:37 
QuestionExporting Emails from Outlook Pin
smarttom999-Jul-06 23:02
smarttom999-Jul-06 23:02 
QuestionVB.NET - How to Drag from Treeview and Drop into DataGrid ? Pin
jo_eylee9-Jul-06 22:00
jo_eylee9-Jul-06 22:00 
Questiontrying to get GC.Keepalive to work Pin
michaelellams9-Jul-06 21:03
michaelellams9-Jul-06 21:03 
Questionprob in ipc WM_COPYDATA with code _ please solve Pin
K edar V9-Jul-06 21:01
K edar V9-Jul-06 21:01 
hi to all and best of luck. Smile | :) )I'm stuck-up here with the problem .. I could manage to pass string to another process/application using WM_COPYDATA but it takes v. long to pass a structure.
i wish if you can give me any code that allows passing "structure" between 2 applications
------------this is class one - sending message
Imports System.Runtime.InteropServices
Public Class clsIPC
Inherits System.Windows.Forms.NativeWindow Implements IDisposable
Private Const GLOBAL_IDENTITY_ONE = "GLOBAL_IDENTITY_ONE"
Private Const GLOBAL_IDENTITY_TWO = "GLOBAL_IDENTITY_TWO"
Private Const MESSAGE_FOR_ONE = "MESSAGE_ONE"
Private Const MESSAGE_FOR_TWO = "MESSAGE_TWO"
Private Const WM_COPYDATA As Integer = &H4A
#Region "API Declaration"
<structlayout(layoutkind.sequential)> _
Private Structure CopyData
Public dwData As IntPtr
Public cbData As Integer
Public lpData As IntPtr
End Structure
Private Declare Auto Function SendMessage Lib "user32" _
(ByVal hWnd As IntPtr, _
ByVal Msg As Integer, _
ByVal wParam As IntPtr, _
ByRef lParam As CopyData) As Boolean
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

#End Region
#Region "process for messanging to application GLOBAL_IDENTITY_TWO"
'get handle of globlal application named GLOBAL_IDENTITY_TWO
Public ReadOnly Property GET_HANDLE_TWO() As IntPtr
Get
Return FindWindow(vbNullString, GLOBAL_IDENTITY_TWO)
End Get
End Property
Structure PT
Dim x As Object
Dim y As Char
Dim xy As String
End Structure
Dim MyVariable As New PT
Public Function sendMessageToTwo()
Dim data As CopyData
Dim message As String = "this is to be sent"
Dim hwndTarget As IntPtr
Dim MessageId As IntPtr
hwndTarget = Me.GET_HANDLE_TWO
MessageId = ONE_TO_TWO_MESSAGEID()
MyVariable.x = message
MyVariable.y = "c"
MyVariable.xy = "String is here"
System.GC.KeepAlive(MyVariable)
data.lpData = Marshal.AllocHGlobal(Marshal.SizeOf(MyVariable))
data.cbData = Marshal.SizeOf(MyVariable)
Dim MyPointer As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(MyVariable))
Marshal.StructureToPtr(MyVariable, data.lpData, True)
SendMessage(hwndTarget, WM_COPYDATA, Me.Handle, data)
MsgBox("WM_COPYDATA")
Exit Function
If Not System.IntPtr.Zero.Equals(hwndTarget) Then
Call PostMessage(hwndTarget, MessageId, 0, 0)
MsgBox("Message sent")
Else
MsgBox("Unable to send Message ! probably GLOBAL_IDENTITY_TWO Not found")
End If
End Function
Public ReadOnly Property ONE_TO_TWO_MESSAGEID() As IntPtr
Get
Static objONE_TO_TWO_MESSAGEID As IntPtr
If IntPtr.Zero.Equals(ONE_TO_TWO_MESSAGEID) Then
objONE_TO_TWO_MESSAGEID = RegisterWindowMessage(MESSAGE_FOR_TWO)
End If
Return objONE_TO_TWO_MESSAGEID
End Get
End Property
#End Region
Region "dispose method and new()/constructor"

Public Sub Dispose() Implements IDisposable.Dispose
If Not Me.Handle.Equals(IntPtr.Zero) Then
Me.ReleaseHandle()
End If
End Sub
Public Sub New()
Dim Params As CreateParams = New CreateParams
Params.Caption = GLOBAL_IDENTITY_ONE
Me.CreateHandle(Params)
End Sub
#End Region
End Class
--------------------------------------xxxxxxxxxxxxxxxxxxxxxxxxxx----------------------------------

----this is class two-listening to message-----------
Imports System.Runtime.InteropServices
Public Class clsIPC
Inherits System.Windows.Forms.NativeWindow Implements IDisposable
Private Const GLOBAL_IDENTITY_ONE = "GLOBAL_IDENTITY_ONE"
Private Const GLOBAL_IDENTITY_TWO = "GLOBAL_IDENTITY_TWO"
Private Const MESSAGE_FOR_ONE = "MESSAGE_ONE"
Private Const MESSAGE_FOR_TWO = "MESSAGE_TWO"
Private Const WM_COPYDATA As Integer = &H4A
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
<structlayout(layoutkind.sequential)> _
Private Structure CopyData
Public dwData As IntPtr
Public cbData As Integer
Public lpData As IntPtr
End Structure
Structure PT
Dim x As Object '<<<----- whenever i use object as member of a structure i get an exception An unhandled exception
'of type 'System.ExecutionEngineException' occurred in mscorlib.dll if i use string as a
'member there is no error
Dim y As Integer
Dim xy As Integer
End Structure

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case WM_COPYDATA
Dim data As CopyData
Dim message As String
Dim MyPoint As New PT
data = CType(m.GetLParam(GetType(CopyData)), CopyData)
MyPoint = Marshal.PtrToStructure(data.lpData, GetType(PT)) <<<---- @ this point i'm getting the error [debug]
'MyPoint = Marshal.PtrToStructure(CType(m.GetLParam(GetType(CopyData)), CopyData).lpData, GetType(PT))
MsgBox(CType(MyPoint.x, String))

Case TWO_TO_ONE_MESSAGEID().ToInt32
MessageBox.Show("GOT A MESSAGE FROM ONE--- CALLING METHOD A", "VBNETMessaging")
Call A()
End Select
MyBase.WndProc(m)
End Sub
Private Sub A()
MsgBox("Message from Method A")
End Sub
Public ReadOnly Property TWO_TO_ONE_MESSAGEID() As IntPtr
Get
Static objTWO_TO_ONE_MESSAGEID As IntPtr

If IntPtr.Zero.Equals(objTWO_TO_ONE_MESSAGEID) Then
objTWO_TO_ONE_MESSAGEID = RegisterWindowMessage(MESSAGE_FOR_TWO)
End If
Return objTWO_TO_ONE_MESSAGEID
End Get
End Property
#Region "dispose method and new()/constructor"
Public Sub Dispose() Implements IDisposable.Dispose
If Not Me.Handle.Equals(IntPtr.Zero) Then
Me.ReleaseHandle()
End If
End Sub
Public Sub New()
Dim Params As CreateParams = New CreateParams
Params.Caption = GLOBAL_IDENTITY_TWO
Me.CreateHandle(Params)
End Sub
#End Region
End Class
--------------------------------------xxxxxxxxxxxxxxxxxxxxxxxxxx----------------------------------

"You can do any thing you set to your mind" - theGhost_k8
AnswerRe: prob in ipc WM_COPYDATA with code _ please solve Pin
Dave Kreskowiak10-Jul-06 4:45
mveDave Kreskowiak10-Jul-06 4:45 
GeneralRe: prob in ipc WM_COPYDATA with code _ please solve Pin
K edar V10-Jul-06 18:30
K edar V10-Jul-06 18:30 
GeneralRe: prob in ipc WM_COPYDATA with code _ please solve Pin
Dave Kreskowiak11-Jul-06 1:47
mveDave Kreskowiak11-Jul-06 1:47 
GeneralRe: prob in ipc WM_COPYDATA with code _ please solve Pin
K edar V11-Jul-06 2:34
K edar V11-Jul-06 2:34 
GeneralRe: prob in ipc WM_COPYDATA with code _ please solve Pin
Dave Kreskowiak11-Jul-06 3:07
mveDave Kreskowiak11-Jul-06 3:07 
GeneralRe: prob in ipc WM_COPYDATA with code _ please solve Pin
K edar V11-Jul-06 18:51
K edar V11-Jul-06 18:51 
QuestionReading/Writing Image Files Socket Problem. Pin
shelal9-Jul-06 20:42
shelal9-Jul-06 20:42 
AnswerRe: Reading/Writing Image Files Socket Problem. Pin
Dave Kreskowiak10-Jul-06 4:42
mveDave Kreskowiak10-Jul-06 4:42 
QuestionDivide Pin
Amarni9-Jul-06 20:02
Amarni9-Jul-06 20:02 
AnswerRe: Divide Pin
Dave Sexton9-Jul-06 21:19
Dave Sexton9-Jul-06 21:19 
GeneralRe: Divide Pin
Amarni9-Jul-06 21:23
Amarni9-Jul-06 21:23 
AnswerRe: Divide Pin
jo_eylee9-Jul-06 22:28
jo_eylee9-Jul-06 22:28 
Questionconnection declaration in class and also how to work with storedprocedures Pin
vengaqua9-Jul-06 19:19
vengaqua9-Jul-06 19:19 
AnswerRe: connection declaration in class and also how to work with storedprocedures Pin
Guffa9-Jul-06 19:33
Guffa9-Jul-06 19:33 
GeneralRe: connection declaration in class and also how to work with storedprocedures Pin
vengaqua9-Jul-06 20:05
vengaqua9-Jul-06 20:05 
AnswerRe: connection declaration in class and also how to work with storedprocedures Pin
Guffa9-Jul-06 23:26
Guffa9-Jul-06 23:26 
Questionproblem in TcpClient.active property Pin
shriveni9-Jul-06 17:06
shriveni9-Jul-06 17:06 

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.