Click here to Skip to main content
15,890,579 members
Home / Discussions / COM
   

COM

 
AnswerRe: C# HELP Web service can not get array of int, or byte from COM object Pin
Mike Dimmick14-Jul-06 4:28
Mike Dimmick14-Jul-06 4:28 
QuestionBig Problem Pin
Ahmed Charfeddine11-Jul-06 1:21
Ahmed Charfeddine11-Jul-06 1:21 
Questionhow to change recipents in outlook2003(vc6) Pin
cpusoft10-Jul-06 21:06
cpusoft10-Jul-06 21:06 
QuestionBSTR and VARIANT Pin
anu_8810-Jul-06 20:59
anu_8810-Jul-06 20:59 
AnswerRe: BSTR and VARIANT Pin
Rory Solley10-Jul-06 22:24
Rory Solley10-Jul-06 22:24 
QuestionCOM is based on what TYPE of DESIGN PATTERN Pin
Balkrishna Talele10-Jul-06 1:38
Balkrishna Talele10-Jul-06 1:38 
AnswerRe: COM is based on what TYPE of DESIGN PATTERN [modified] Pin
Machhindra10-Jul-06 23:04
Machhindra10-Jul-06 23:04 
Questioncan i pass object through IPC in .net ? code inn Pin
K edar V9-Jul-06 21:02
K edar V9-Jul-06 21:02 
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: can i pass object through IPC in .net ? code inn Pin
Eran Aharonovich11-Jul-06 11:02
Eran Aharonovich11-Jul-06 11:02 
QuestionDCOM in service Pin
Greg_moon9-Jul-06 7:31
Greg_moon9-Jul-06 7:31 
QuestionHow do I invoke MySQL from a Com object Pin
Ger Hayden8-Jul-06 4:42
Ger Hayden8-Jul-06 4:42 
AnswerRe: How do I invoke MySQL from a Com object Pin
Malli_S10-Jul-06 1:26
Malli_S10-Jul-06 1:26 
QuestionHow do I call a dll from a com object Pin
Ger Hayden8-Jul-06 4:37
Ger Hayden8-Jul-06 4:37 
AnswerRe: How do I call a dll from a com object Pin
peterchen8-Jul-06 5:28
peterchen8-Jul-06 5:28 
QuestionFile Not found calling C# COM assembly from C++ [modified] Pin
JakeWyman8-Jul-06 1:30
JakeWyman8-Jul-06 1:30 
QuestionCom interface call retuns error "Not enough storage is available to complete this operation" Pin
george_thomas6-Jul-06 20:32
george_thomas6-Jul-06 20:32 
QuestionInstances of COM Objects Pin
HakunaMatada6-Jul-06 20:09
HakunaMatada6-Jul-06 20:09 
AnswerRe: Instances of COM Objects Pin
Lim Bio Liong6-Jul-06 22:30
Lim Bio Liong6-Jul-06 22:30 
GeneralRe: Instances of COM Objects Pin
george_thomas9-Jul-06 20:00
george_thomas9-Jul-06 20:00 
GeneralRe: Instances of COM Objects Pin
Lim Bio Liong9-Jul-06 21:01
Lim Bio Liong9-Jul-06 21:01 
QuestionCalling COM from C# managed code Pin
sony alex6-Jul-06 0:47
sony alex6-Jul-06 0:47 
QuestionPassing a string from C to VB Pin
Bratis5-Jul-06 22:04
Bratis5-Jul-06 22:04 
AnswerRe: Passing a string from C to VB Pin
peterchen8-Jul-06 5:31
peterchen8-Jul-06 5:31 
Questionerror importing api Pin
nikhil_ag19855-Jul-06 20:04
nikhil_ag19855-Jul-06 20:04 
QuestionBlinking Windowless activex ATL control Pin
emilmih5-Jul-06 11:39
emilmih5-Jul-06 11:39 

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.