Consuming unmanaged .Exe (?) <newbie>

  • Thread starter Thread starter Mr.Baha
  • Start date Start date
M

Mr.Baha

Hello,
I have a situation where I want to consume VC++ code that someone else
has written. This C++ code compiles into a console app exe, and I have
all of it's source code. For the record, this app listens to a comm
port for a stream of proprietary data it is expecting.


What I want to do with it is be able to instantiate this "listener()"
function from my C# WinForm and display it's console output to my
Textbox. If this C++ code compiled into a DLL I could use the
PInvoke, but it compiles into a .exe and I do not know how to change
this within the project(in vstudio6). It also does not implement any
COM interfaces for me to use.


Can anybody tell me any glaring things that I am overlooking to be able
to use this unmananged method?
Thanks


Mr.Baha
 
I can think of a number of solutions but I have no access to my
development
cpu.

1) I would first try to create an empty win32 dll project and copy and
paste
the c++ code redirecting the output to a LPTSTR and receiving the output
as
a c# stringbuffer.
2) A more general solution would be to create an ATL COM dll project and
copy and paste the code redirecting the output to a [out,ret] BSTR.
But both 1 and 2 would ? need to block until input was detected.
3) A more interesting solution would be to create a C# delegate and have
the
C++ dll callback the C# program when input is intercepted.
4) Finally there surely must be a way to launch the exe from C# and
redirect
cout.

Regards,
Jeff
If this C++ code compiled into a DLL I could use the
PInvoke, but it compiles into a .exe and I do not know how to change
this within the project(in vstudio6).<
 
Back
Top