473,394 Members | 1,726 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,394 software developers and data experts.

exchanging data between a win32 application (service) and a c# application (service)

Hi,

I have a C# service application - and a Win32 / C++ service application
running on my system.

I need someway to interact between those two - the Win32 application is pure
Win32 - so im not using any components or anything like that.

The 2 alternatives i could think of was, messages or creating a TCP/IP
socketserver on the C# end, so i could control it that way.

The socket approach is abit overkill i feel - but i do need to be able to
transfer data packets somehow ?

I am not that sharp in C# - do anybody know how to do this the smartest way
?

Thanx,
Nov 17 '05 #1
8 5032
"dthom" <no********@nospamthanks.nu> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I need someway to interact between those two


Please be a bit more specific about what you mean by "interact".

Do you want both apps to share data?

Do you want both apps to be able to start / stop the other?

Do you want one app to "monitor" the activity of the other somehow?
Nov 17 '05 #2
Depening on what you want you can either use XML Webservices, .NET Remoting
or DCOM

If you can be more specific about what you want and it wil run on your
intranet or not, ... I'm pretty sure that people here can provide feedback

Gabriel Lozano-Morán
"dthom" <no********@nospamthanks.nu> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,

I have a C# service application - and a Win32 / C++ service application
running on my system.

I need someway to interact between those two - the Win32 application is
pure Win32 - so im not using any components or anything like that.

The 2 alternatives i could think of was, messages or creating a TCP/IP
socketserver on the C# end, so i could control it that way.

The socket approach is abit overkill i feel - but i do need to be able to
transfer data packets somehow ?

I am not that sharp in C# - do anybody know how to do this the smartest
way ?

Thanx,

Nov 17 '05 #3
Sometimes, socket is not as hard as you imagine, and I would suggest you
go that approach.

Jianwei
dthom wrote:
Hi,

I have a C# service application - and a Win32 / C++ service application
running on my system.

I need someway to interact between those two - the Win32 application is pure
Win32 - so im not using any components or anything like that.

The 2 alternatives i could think of was, messages or creating a TCP/IP
socketserver on the C# end, so i could control it that way.

The socket approach is abit overkill i feel - but i do need to be able to
transfer data packets somehow ?

I am not that sharp in C# - do anybody know how to do this the smartest way
?

Thanx,

Nov 17 '05 #4
"Gabriel Lozano-Morán" wrote:
Depening on what you want you can either use XML Webservices, .NET Remoting
or DCOM

If you can be more specific about what you want and it wil run on your
intranet or not, ... I'm pretty sure that people here can provide feedback

Gabriel Lozano-Morán
"dthom" <no********@nospamthanks.nu> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,

I have a C# service application - and a Win32 / C++ service application
running on my system.

I need someway to interact between those two - the Win32 application is
pure Win32 - so im not using any components or anything like that.

The 2 alternatives i could think of was, messages or creating a TCP/IP
socketserver on the C# end, so i could control it that way.

The socket approach is abit overkill i feel - but i do need to be able to
transfer data packets somehow ?

I am not that sharp in C# - do anybody know how to do this the smartest
way ?

Thanx,


I may be working on the same problem and am trying to use Interop. Both
processes are on the same CPU. One is a C# Windows Applications using Windows
Forms. The other is a C++ application written to the Win32 SDK and interfaces
with the serial port using SetCommMask, WaitCommEvent,
WaitForMultipleObjects, and GetCommModemStatus.

My plan is to merge them into one process with two different threads of
execution.

My suggestion is to look at using System.Runtime.InteropServices;
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, UIntPtr wParam,
IntPtr lParam);

Nov 17 '05 #5
Well to clarify, it is simple two applications (running as services) running
on the same PC.

Thats also why i find socketcommunciation to and from localhost abit
overkill - its not that its hard (the PC applications is in fact a
socketserver) - but i just hoped there was somekind of messaging system /
memory-mapped-file similiar kindof sharing data between processes.

The problem ofcourse, the one is CSharp, the other is C++ - and i dont have
the full overview over CSharp as i do with C++.

Nov 17 '05 #6
Well by interact i mean:

1. Send a COMMAND, and a datablock with data (to be used by the client)
2. Recieve a COMMAND (normally an answer on a previously sent command)

I would prefer both data to be able to share data yes.

I dont need to start / stop the other - but it could be an issue from my C++
application to at least start the cSharp application at some point (of it
goes ballistic).

No monitoring - the CSharp is handling communication to a special device, in
a way that i cannot incooporate in my C++ application (which is a very very
crucial application that handles alot of tasks) - in the CSharp i dont have
the full overview over the code lying beneath since its using 3.rd. party
products - therefore it is a demand that this application is seperated from
the very critical serverapplication.

So if the CSharp applications crashes bigtime, it doesnt affect my C++
application - thats the main reason - the secondary is that it would be a
huge job to incooperate the functionality from the CSharp into the server.
"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> skrev i en meddelelse
news:O0*************@TK2MSFTNGP09.phx.gbl...
"dthom" <no********@nospamthanks.nu> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I need someway to interact between those two


Please be a bit more specific about what you mean by "interact".

Do you want both apps to share data?

Do you want both apps to be able to start / stop the other?

Do you want one app to "monitor" the activity of the other somehow?

Nov 17 '05 #7
I'd use a socket.

Nov 17 '05 #8
My suggestion is to look at using System.Runtime.InteropServices;
Here is some code that I wrote to send a message to another process on the
same box.
[DllImport("user32.dll")]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, UIntPtr wParam,
IntPtr lParam);

[DllImport("user32.dll", SetLastError=true, CharSet=CharSet.Auto)]
static extern uint RegisterWindowMessage(string lpString);

private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
if (checkBox1.Checked)
{
IntPtr handle = FindWindow(null, "xxx Monitor");
if(handle != IntPtr.Zero)
{
uint x_GenerateEvent = RegisterWindowMessage("ZM_GenerateEvent");
SendMessage(handle, x_GenerateEvent, UIntPtr.Zero, IntPtr.Zero);

int attempts = 0;
while (attempts < 5)
{
Thread.Sleep(1000); // allow the file to be created by other process
if (WorkOnFile() == true)
break;
attempts++;
}
if (attempts == 5)
{
MessageBox.Show("file not found by WorkOnFile()");
}
else
{
checkBox1.Checked = false;
}
}
else
{
MessageBox.Show("Cannot find xxx Monitor window");
}
}
}

Note: The "xxx Monitor" process written in C creates a file after I send a
message.

hope it helps --tony
"dthom" wrote:
Well to clarify, it is simple two applications (running as services) running
on the same PC.

Thats also why i find socketcommunciation to and from localhost abit
overkill - its not that its hard (the PC applications is in fact a
socketserver) - but i just hoped there was somekind of messaging system /
memory-mapped-file similiar kindof sharing data between processes.

The problem ofcourse, the one is CSharp, the other is C++ - and i dont have
the full overview over CSharp as i do with C++.

Nov 17 '05 #9

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

Similar topics

9
by: esafran | last post by:
Hi, I've have encountered a very strange behaviour under C#. My application is registering for: Microsoft.Win32.SystemEvents.DisplaySettingsChanged &...
3
by: Sarah | last post by:
I have a function residing in a module that is doing some file copy and database query operations. This function is called from a regular form under a System.Windows.Forms.Timer control. The...
4
by: Josema | last post by:
Hi to all, Im searching a hand to solve an Exception that i get when i try to give the user to a gmail account... Any help would be appreciated.. Thanks in advance This is a piece of my...
3
by: Alwin | last post by:
Hey All! I am currently designing a database model for (at first sight) a simple order entry program. The problem I'm currently facing is the exchange of data between the databases of each branch...
2
by: Al | last post by:
Hello, I want my python application to communicate with an legacy C program which read/write data in a shared memory (Unix Sys V IPC). It seems that there are no official shm nor sysV ipc...
4
by: Thomas Eichner | last post by:
Hi, does anybody know a public website which offers a service that displays all data send by a browser (or an app calling the website), especially HTTP GET and POST data, browser data etc.? I...
0
by: jbenezech | last post by:
Hi all , I have a perl/java app running under Win32. The application consists of a perl service (Win32::Daemon) and of java classes. The perl service calls every xx hours java classes to perform...
0
by: Gianluca Pezzoli | last post by:
Hi, I have Windows Server 2003 x64 standard SP2 Italian, with Xeon 3.8 Ghz and 2GB RAM. On Server I found installed .net framework 1.1 and 2.0 (x64). I am developing a simple (Hello world)...
1
by: manishabh77 | last post by:
I will be obliged if anybody can help me with this problem: I am trying to extract data from an excel sheet that matches IDs given in column 4 of the excel sheet.I have stored those query IDs in an...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.