Calling VC++ From VB.NET

  • Thread starter Thread starter Mark Jerde
  • Start date Start date
M

Mark Jerde

I have been searching google, google groups and MSDN but haven't found any
simple examples yet. Suggestions and/or URLs would be appreciated!

I need to write some ISO C++ functions to verify data streams. (It is
expected these will also eventually be run in Linux.) The application also
needs a management GUI. For Windows I plan to write the GUI in VB .NET
2003.

How do I call C++ from VB.NET? I'm trying to start small:

bool AlwaysReturnsTrue(void)

and work up to:

bool StreamIsValid(IN ByteArray, IN Length, OUT ErrorMessage, OUT ErrorByte)


I'm uncertain about memory issues: Who allocates, etc. I'm also unclear
about internalization of the error messages.

Thanks.

-- Mark
 
I have been searching google, google groups and MSDN but haven't found any
simple examples yet. Suggestions and/or URLs would be appreciated!

I need to write some ISO C++ functions to verify data streams. (It is
expected these will also eventually be run in Linux.) The application also
needs a management GUI. For Windows I plan to write the GUI in VB .NET
2003.

Why don't you write it in java, then you won't even have to write a
different one for linux.
How do I call C++ from VB.NET? I'm trying to start small:

Use Declare.
bool AlwaysReturnsTrue(void)

and work up to:

bool StreamIsValid(IN ByteArray, IN Length, OUT ErrorMessage, OUT ErrorByte)

Read up on System.InteropServices.Marshal et al.
I'm uncertain about memory issues: Who allocates, etc. I'm also unclear
about internalization of the error messages.

Caller allocates. .NET also has some 'magic' classes such as
StringBuilder that can be 'passed to be filled' without having a maximum
size pre-specified - this is done by the GC.
 
bonj said:
Why don't you write it in java, then you won't even have to write a
different one for linux.

I don't know Java... ;-) I installed Eclipse but couldn't get the
examples to run. I also installed Borland's free Java IDE and it works but
Java looks to have quite a learning curve. I wrote a lot of VB5/6 code and
have written a few small VB.NET programs. (Nested classes are great!) For
now I want to stay with something I (sorta) know.

-- Mark
 
I don't know Java...


Neither do I, but it doesn't stop me ;-)
I installed Eclipse but couldn't get the
examples to run. I also installed Borland's free Java IDE and it works
but Java looks to have quite a learning curve.

Install the Java SDK from sun.java.com. There's also the netbeans IDE,
but I find it poor and don't use it. The way I see it, it's more fun
to learn what has to be learnt to get what I want done than it is to write
the same logic twice.
I wrote a lot of VB5/6
code and have written a few small VB.NET programs. (Nested classes are
great!) For now I want to stay with something I (sorta) know.

Java is very similar to C#. And C# is very similar to VB.NET (sort of).
But you need to ask yourself, do you want a GUI to be able to run on
linux? If you do, and you already know a language / libraries to do that,
then you're sorted - go with your original plan. Or maybe you only need
the GUI on windows. But all I was thinking was, if it's more a case of
"I'll cross that bridge when I come to it" for the GUI on linux, then you
might end up finding that java is the best option anyway - and you'll kick
yourself if you've already spent ages writing a program in .NET on windows.

good luck with it though whatever you decide!
 
Back
Top