Accessing DLL in VB.Net


I'm trying to connect to a swipe card machine and need a hand getting started.  The developers of the machines have given me a DLL and a manual but as it's not VB I'm lost and just need a hand getting the initial connection working, once I get that started I'll be good...I hope.

So I've got this DLL and instructions like this:


It is envisaged that future enhancements might be made to the driver, which might affect the programming interface available to a calling application. An application should enquire the driver's version information before calling any other function.

int FbBrg_Version(char *Dst, int Len);

Fills the supplied destination buffer with the drivers version string.

The argument 'Dst' specifies where the string should be copied to and 'Len' specifies the size of the destination buffer.

The drivers null terminated version string is copied to the specified buffer. If the destination buffer is too small for the complete string, then a null character is placed at the last position; i.e., the string is truncated.

The return value specifies the full length of the available version string (including the null terminator) and may be larger than the amount transferred.

So, using the dll provided, how do I run this command (FbBrg_Version) and get the result?  There are other commands but once I figure out how to run this one the rest will hopefully folow suit.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Luis PérezSoftware Architect in .NetCommented:
Try this:

Public Declare Auto Function FbBrg_Version Lib "your_dll.dll" (ByVal Dst As String, ByVal lpLen As Integer) As Integer

'And call the function this way:

Dim buffer As String = Space(1000) 'Or a proper value depending on the result that you expect
Dim iLength As Integer = buffer.Length
Dim ret As Integer = FbBrg_Version(buffer, iLength)

'Probably you may need to truncate the result:
buffer = buffer.Substring(0, ret)

Hope that helps. Note that in order to work you must locate your dll in the \bin directory of the application, or in any of the directories of the path of your system: windows, windows\system, etc.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Haris VCommented:
lee_murphyAuthor Commented:
Thank you very much!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.