Accessing DLL in VB.Net

Posted on 2008-11-18
Last Modified: 2012-05-05

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.
Question by:lee_murphy
    LVL 25

    Accepted Solution

    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.
    LVL 8

    Expert Comment

    by:Haris V

    Author Closing Comment

    Thank you very much!

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now