Code: Select all
Dim Error_Message As Integer
Dim Start_Address As Integer
Dim Num_Units As Integer
Dim Product_Name As String
Private Declare Function Init Lib "PM3DDICP.dll" Alias "tkcmdsetDDI_init" () As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox1.Text = 999
Refresh()
Error_Message = Init()
If Error_Message = 0 Then
TextBox2.Text = "Init 0k!"
TextBox1.Text = Error_Message
Else
TextBox2.Text = "Init Error!"
TextBox1.Text = Error_Message
End If
Refresh()
End Sub
An unhandled exception of type 'System.AccessViolationException' occurred in DLLTest.exe
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Here is the code for the discover_pm3s call:
Code: Select all
<DllImportAttribute("PM3DDICP.dll", EntryPoint:="tkcmdsetDDI_discover_pm3s",
SetLastError:=True, CharSet:=CharSet.Unicode,
ExactSpelling:=True,
CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function Discover_PM3s(ByVal Product_Name As String, ByVal Start_Address As Integer, Num_Units As Integer) As Integer
' This function gives the number of pm3s connected to the computer.
' Leave this function empty. The DLLImport attribute forces calls
' to Discover_PM3s to be forwarded to tkcmdsetDDI_discover_pm3s in PM3DDICP.DLL.
End Function
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Error_Message = Discover_PM3s(Product_Name, 0, Num_Units)
TextBox1.Text = 999
Refresh()
If Error_Message = 0 Then
TextBox2.Text = "0k!"
TextBox1.Text = Error_Message
Else
TextBox2.Text = "Error!"
TextBox1.Text = Error_Message
End If
Refresh()
End Sub
Code: Select all
Private Declare Function Discover_PM3s Lib "PM3DDICP.dll" Alias "tkcmdsetDDI_discover_pm3s" (ByVal Product_Name As String, ByVal Start_Address As Integer, Num_Units As Integer) As Integer
This is the post (and those linked within it) that I have used to get this far:
http://www.c2forum.com/viewtopic.php?f= ... rapper+dll