Question VB and third party Library/DLL

Jeff Whittle

New member
Joined
Dec 3, 2012
Messages
1
Programming Experience
10+
I'm looking at porting a well established Fortran application to VB.NET.

I need to call some routines in a third party library that is written in C and expects to be called from C. Is this possible from VB.NET. If so, how?
 
You can use Platform Invoke (pinvoke) to call functions exported by C/C++ libraries. That's exactly how Windows API functions are called in .NET code. Basically, you write a proxy method in VB or C# with a compatible signature and map it to the external library function. You then call your method in .NET like you would any other method. You can use the Declare keyword on your method or, preferably, apply the DllImport attribute to it. If you want to see some examples then I'd search the web for usages of the SendMessage and FindWindow functions, which are probably the two most commonly called Windows API functions.
 
Thank you very much. I've now found a nice example, and I'm sure I can work from that.

Sorry to be slow replying but something went wrong with my login and I couldn't get back in - I could find no way of resetting my password without logging in first! As you see I have now created a second login.
 
Back
Top