I'm using a DLL and a tutorial how to use some function in VB.
The problem is I'm not familiar with VB and I need to implement in C#
This is the tutorial in VB
Private Declare Function InitComm Lib "pf500.dll" (ByVal portnum As Byte) As Long
Private Declare Function SendCommand Lib "pf500.dll" Alias "WriteCommand" (ByVal porthnd As Long, ByVal seq As Byte, ByVal vlez As String, ByVal izlez As Long, ByVal stats As Long) As Integer
Public Function WriteCommand(ByVal com_port As Byte, ByVal seq As Byte, ByVal sVlez As String, ByRef sIzlez As String, ByRef sStatus As String) As Integer
sIzlez = String$(256, vbNullChar)
sStatus = String$(256, vbNullChar)
Dim lngPortHandle As Long
Dim lngIzlez As Long
Dim lngStatus As Long
lngIzlez = StrPtr(sIzlez)
lngStatus = StrPtr(sStatus)
If ((seq < 32) Or (seq > 127)) Then
sIzlez = "Sekventniot broj MORA da pripagja vo intervalot od [32,127]"
sStatus = "GRESEN Sekventen broj"
Exit Function
End If
If (Len(sVlez) = 0) Then
sIzlez = "Parametarot vlez e cmd+data, znaci -mora- da bide min. 1 znak dolg"
sStatus = "GRESNA vrednost za parametarot vlez"
Exit Function
End If
lngPortHandle = InitComm(com_port)
If lngPortHandle > 0 Then
If (SendCommand(lngPortHandle, seq, sVlez, lngIzlez, lngStatus) >= 0) Then
sIzlez = AnsiZtoString(lngIzlez)
sStatus = AnsiZtoString(lngStatus)
Else
sIzlez = "Neuspeshno prakjanje/primanje na podatoci od COM" + str(com_port)
sStatus = "GRESKA"
End If
CloseComm (lngPortHandle)
Else
sIzlez = "Portot COM" + str(com_port) + " ne e pronajden!"
sStatus = "GRESKA"
End If
and this is how i use InitComm
[DllImport("pf500.dll", CharSet = CharSet.Unicode)]
public static extern long InitComm(byte s);
and works good
the problem is on sendcommand???
i have no ideo what means alias writecommand
[DllImport("pf500.dll", CharSet = CharSet.Unicode)]
public static extern int WriteCommand(long portnum, byte seq, string hyrje, long dalje, long stats);
this is how i try it but i got error like this
"Unable to find an entry point named 'Send Command' in DLL 'pf500.dll'."
The problem is how to implement in C# this one:
Private Declare Function SendCommand Lib "pf500.dll" Alias "WriteCommand" (ByVal porthnd As Long, ByVal seq As Byte, ByVal vlez As String, ByVal izlez As Long, ByVal stats As Long) As Integer
sorry for my bad english