[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

Accessing DLL in VB.Net

Hi,

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:

-------------------------------------------------------------------------------------
DRIVER INTERROGATION

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.
0
lee_murphy
Asked:
lee_murphy
1 Solution
 
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.
0
 
Haris VCommented:
0
 
lee_murphyAuthor Commented:
Thank you very much!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now