473,387 Members | 1,290 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Pass data between 2 applications

Hi all,

I have 2 applications one in VB.net and the other in VC6. I need to
pass data between them. How can I do it? what's the best way to
implement such communication ?
Any comment will be appreciate.
Thank you.

Juky

Nov 21 '05 #1
6 5297
"juky" <ju*******@yahoo.com> schrieb:
I have 2 applications one in VB.net and the other in VC6. I need to
pass data between them. How can I do it? what's the best way to
implement such communication ?


You can set up communication using 'WM_COPYDATA', for example:

<URL:http://groups.google.de/groups?selm=uWYQZLWjDHA.3312%40tk2msftngp13.phx.gb l>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2

You might use COM for this

VC6 and VB.NET both support it

Michel Posseth



"juky" <ju*******@yahoo.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
Hi all,

I have 2 applications one in VB.net and the other in VC6. I need to
pass data between them. How can I do it? what's the best way to
implement such communication ?
Any comment will be appreciate.
Thank you.

Juky

Nov 21 '05 #3

Herfried K. Wagner [MVP] wrote:
"juky" <ju*******@yahoo.com> schrieb:
I have 2 applications one in VB.net and the other in VC6. I need to
pass data between them. How can I do it? what's the best way to
implement such communication ?
You can set up communication using 'WM_COPYDATA', for example:

<URL:http://groups.google.de/groups?selm=uWYQZLWjDHA.3312%40tk2msftngp13.phx.gb l>
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


I just checked your link about WM_COPYDATA, it's pretty useful. I
copied below the example.The problem is to synchronize sender and
receiver with Sender and receiver on the other application written in
VC6. How should Sender and receiver look like in VC if I want to use
this vb.net example in application-1?

Thanks,
Juky

Application 1 - the receiver...

Imports System.Runtime.InteropServices

Public Class MainForm
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Messages As System.Windows.Forms.ListBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.Messages = New System.Windows.Forms.ListBox()
Me.SuspendLayout()
'
'Messages
'
Me.Messages.Dock = System.Windows.Forms.DockStyle.Fill
Me.Messages.IntegralHeight = False
Me.Messages.Name = "Messages"
Me.Messages.Size = New System.Drawing.Size(292, 273)
Me.Messages.TabIndex = 0
'
'MainForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.AddRange(New System.Windows.Forms.Control()
{Me.Messages})
Me.Name = "MainForm"
Me.Text = "Receive WM_COPYDATA"
Me.ResumeLayout(False)

End Sub

#End Region

Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
If m.Msg = MainForm.WM_COPYDATA Then
Dim data As CopyData
Dim message As String

' get the data...
data = CType(m.GetLParam(GetType(CopyData)), CopyData)
message = Marshal.PtrToStringAuto(data.lpData, data.cbData
\
Marshal.SystemDefaultCharSize)

' add the message
Messages.Items.Add(String.Format("{0}: {1}",
DateTime.Now.ToShortTimeString(), message))

' let them know we processed the message...
m.Result = New IntPtr(1)
Else
MyBase.WndProc(m)
End If
End Sub

Private Const WM_COPYDATA As Integer = &H4A

<StructLayout(LayoutKind.Sequential)> _
Private Structure CopyData
Public dwData As IntPtr
Public cbData As Integer
Public lpData As IntPtr
End Structure
End Class
Application 2 - The sender....

Imports System.Runtime.InteropServices

Public Class MainForm
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents MessageText As System.Windows.Forms.TextBox
Friend WithEvents Send As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.MessageText = New System.Windows.Forms.TextBox()
Me.Send = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'MessageText
'
Me.MessageText.Anchor = ((System.Windows.Forms.AnchorStyles.Top
Or
System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.MessageText.Name = "MessageText"
Me.MessageText.Size = New System.Drawing.Size(328, 20)
Me.MessageText.TabIndex = 0
Me.MessageText.Text = ""
'
'Send
'
Me.Send.Anchor = System.Windows.Forms.AnchorStyles.Top
Me.Send.Location = New System.Drawing.Point(127, 32)
Me.Send.Name = "Send"
Me.Send.TabIndex = 1
Me.Send.Text = "Send"
'
'MainForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(328, 61)
Me.Controls.AddRange(New System.Windows.Forms.Control()
{Me.Send,
Me.MessageText})
Me.Name = "MainForm"
Me.Text = "Send Data To Client Using WM_COPYDATA"
Me.ResumeLayout(False)

End Sub

#End Region

Private Const WM_COPYDATA As Integer = &H4A
Private Const WindowName As String = "Receive WM_COPYDATA"

<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 Auto Function FindWindow Lib "user32" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As IntPtr

Private Sub Send_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Send.Click
Dim ClientWindow As IntPtr = MainForm.FindWindow(Nothing,
MainForm.WindowName)

' make sure we found an active client window
If Not ClientWindow.Equals(IntPtr.Zero) Then

' if there is text to send
If Me.MessageText.Text.Length > 0 Then
Dim message As String = Me.MessageText.Text
Dim data As CopyData

' set up the data...
data.lpData = Marshal.StringToHGlobalAuto(message)
data.cbData = message.Length *
Marshal.SystemDefaultCharSize

' send the data
MainForm.SendMessage(ClientWindow,
MainForm.WM_COPYDATA,
Me.Handle, data)

' free the pointer...
Marshal.FreeHGlobal(data.lpData)
End If
Else
MessageBox.Show("Could Not Find Active Client Window.")
End If
End Sub
End Class

Nov 21 '05 #4
Michel,

I also tried with COM but I don't know how to save permanently a data
in my DLL and get accessible from APPLIC2.

APPLIC1(VB.NET)---------DLL----------APPLIC2 (VC6)

How can I share DLL context (filled by APPLIC1) in APPLIC2?....and vice
versa.

Thanks,
Juky

Nov 21 '05 #5
u can use , socket programming in that, the vc++ would have the
listening socket and vb.net have the connection socket initially, use
xml for data passing.

Nov 21 '05 #6
Try to use shared dll data:
http://www.codeproject.com/dll/data_seg_share.asp

Serge

"juky" <ju*******@yahoo.com> a écrit dans le message de news:
11*********************@l41g2000cwc.googlegroups.c om...
Michel,

I also tried with COM but I don't know how to save permanently a data
in my DLL and get accessible from APPLIC2.

APPLIC1(VB.NET)---------DLL----------APPLIC2 (VC6)

How can I share DLL context (filled by APPLIC1) in APPLIC2?....and vice
versa.

Thanks,
Juky

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: vishal | last post by:
when a user clicks on a hyperlink i want to pass data to linked page. but what i want is that this data should not be visible to user. i mean is there any way that i can pass data except get method...
2
by: Matt | last post by:
How to pass data back and forth between ASP and JSP page? Let's say I have Java objects, how to pass the data back to ASP page?? Or ASP has data, how to pass the data to JSP page?? Please...
0
by: Matt | last post by:
My problem is to allow ASP to interact with JSP, and I pass JavaScript object in my approach, but I wonder if it will work in network, not just in local machine. For testing purposes, the...
7
by: Matt | last post by:
In ASP, when we pass data between pages, we usually pass by query string. If we pass data by query string, that means we need to use submit button, not by regular button, and the form will pass to...
3
by: Hong | last post by:
Hi Group, I hope I got into the right place. If I have two different C++ programs (exe). Is there anyway I can pass data (numbers, strings, etc) between the 2 programs (without combining into 1...
3
by: juky | last post by:
Hi all, I have 2 applications one in VB.net and the other in VC6. I need to pass data between them. How can I do it? what's the best way to implement such communication ? Any comment will be...
2
by: Anil Pundhir | last post by:
What is the best way to pass data to a web service. The client(to send data) has .net environment and also the server on which the web service is hosted also has the .net environment. Should I...
1
by: Jacksm | last post by:
I have an asp.net 2.0 web application and I am looking to pass data from that to another window application or web application window that is open on my computer.
3
Frinavale
by: Frinavale | last post by:
I've created a few ASP.NET Ajax Enable Server controls. There are 2 components to these controls: a server side Object that deals with the server side stuffs, and a client side Object that deals...
8
by: Ariel White | last post by:
What does it mean to pass data by value and how does that compare to passing data by reference? Please explain to me why we would pass some data by value and others by reference.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.