by Luis Mariscal (11 Submissions)
Category: OLE/COM/DCOM/Active-X
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 31st January 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Source code how make a DLL for manage LPT1 Parallel port and work with 4 inputs and 4 output , You can decode dtmf with a 8870 chip or manage
API Declarations
Public Declare Function DlPortReadPortUchar Lib "dlportio.dll" (ByVal Port As Long) As Byte
Public Declare Function DlPortReadPortUshort Lib "dlportio.dll" (ByVal Port As Long) As Integer
Public Declare Function DlPortReadPortUlong Lib "dlportio.dll" (ByVal Port As Long) As Long
Public Declare Sub DlPortReadPortBufferUchar Lib "dlportio.dll" (ByVal Port As Long, Buffer As Any, ByVal Count As Long)
Public Declare Sub DlPortReadPortBufferUshort Lib "dlportio.dll" (ByVal Port As Long, Buffer As Any, ByVal Count As Long)
Public Declare Sub DlPortReadPortBufferUlong Lib "dlportio.dll" (ByVal Port As Long, Buffer As Any, ByVal Count As Long)
Public Declare Sub DlPortWritePortUchar Lib "dlportio.dll" (ByVal Port As Long, ByVal Value As Byte)
Public Declare Sub DlPortWritePortUshort Lib "dlportio.dll" (ByVal Port As Long, ByVal Value As Integer)
Public Declare Sub DlPortWritePortUlong Lib "dlportio.dll" (ByVal Port As Long, ByVal Value As Long)
Public Declare Sub DlPortWritePortBufferUchar Lib "dlportio.dll" (ByVal Port As Long, Buffer As Any, ByVal Count As Long)
Public Declare Sub DlPortWritePortBufferUshort Lib "dlportio.dll" (ByVal Port As Long, Buffer As Any, ByVal Count As Long)
Public Declare Sub DlPortWritePortBufferUlong Lib "dlportio.dll" (ByVal Port As Long, Buffer As Any, ByVal Count As Long)
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Function BinToDec%(BinNumber$)
Dim Weight%
Dim Dec%
Dim i%
Weight% = 1
Dec% = 0 'Reset decimal number
If BinNumber$ <> "00000000" Then
For i% = Len(BinNumber$) To 1 Step -1
If Mid$(BinNumber$, i%, 1) = "1" Then
Dec% = Dec% + Weight% 'If bit=1 then add weigth factor
End If
Weight% = Weight% * 2 'Multiply weight factor by 2
Next
BinToDec% = Dec% 'Store result
Else
BinToDec% = 0
End If
End Function
Function DecToBin$(Decnumber%)
'Conversion of decimal number (0...255) to 8 bit binary string.
'--------------------------------------------------------------
Dim Bin$
Dim Faktor%, i%
Bin$ = ""
Faktor% = 128
If Decnumber% <> 0 Then
For i% = 1 To 8
If Faktor% > Decnumber% Then
Bin$ = Bin$ + "0"
Else
Bin$ = Bin$ + "1"
Decnumber% = Decnumber% - Faktor%
End If
Faktor% = Faktor% \ 2
Next
DecToBin$ = Bin$
Else
DecToBin$ = "00000000"
End If
End Function
' that are the drivers for usage LPT1 in Vbasic
' If you want email me and I send the
' Dllportio Install and self registered
' [email protected]
'
' Usage
' OUTPUT
' puerto1.enviar(number) --> send data to port
' puerto1.enviar(0) --> put all output in low state 0 volt
' puerto1.enviar(255) --> put all output in high state 5 volts
' INPUT
' text1.text = puerto1.entrada --> only a number entered into a INPUT
' text2.text = puerto1.codigo --> the entery string entered on an INPUT
' ( I do not write in english very well I am Argentine)
' the timer1 interval = 10
Public entrada As String
' puerto.ctl
' user control
' Declaraciones de variables generales
Public Codigo
Public b
Public Puerto
Public AntiIntrusos As Integer
Sub enviar(salida As Integer)
' Call the DLL for send data to port
' puerto1.enviar(number)
' send +5v to specific pin of LPT1 ( 2 to 5)
DlPortWritePortUchar &H378, salida
End Sub
Private Sub Timer1_Timer()
If Puerto = "" Then
Puerto = &H379 ' define port if isnt defined
End If
If AntiIntrusos = 0 Then
AntiIntrusos = 10
End If
Dim numero
numero = (127 - DlPortReadPortUchar(Puerto)) / 8
If numero = 11 Then
entrada = "*"
End If
If numero = 12 Then
entrada = "#"
End If
If numero = 10 Then
entrada = "0"
End If
If numero = 13 Then
entrada = "A"
End If
If numero = 14 Then
entrada = "B"
End If
If numero = 15 Then
entrada = "C"
End If
If numero < 10 Then
entrada = Trim(Str$(numero))
End If
If numero = 0 Then b = 0
If numero = 0 Then
If Counter > AntiIntrusos Then
Counter = 0
Codigo = ""
End If
End If
If b <> numero Then
Counter = 0
If numero <> 0 Then
b = numero
If numero = 11 Then
nro = "*"
End If
If numero = 12 Then
nro = "#"
End If
If numero = 10 Then
nro = "0"
End If
If numero = 13 Then
nro = "A"
End If
If numero = 14 Then
nro = "B"
End If
If numero = 15 Then
nro = "C"
End If
If numero < 10 Then
nro = Str$(numero)
End If
Codigo = Trim(Codigo) & Trim(nro)
End If
End If
End Sub
Private Sub UserControl_Initialize()
End Sub
No comments have been posted about Source code how make a DLL for manage LPT1 Parallel port and work with 4 inputs and 4 output , You . Why not be the first to post a comment about Source code how make a DLL for manage LPT1 Parallel port and work with 4 inputs and 4 output , You .