Codice:
Declare Function CreateFile Lib "kernel32" Alias "CreateFileA"
(ByVal lpFileName As String,
ByVal dwDesiredAccess As Long,
ByVal dwShareMode As Long,
ByVal lpSecurityAttributes As Long,
ByVal dwCreationDisposition As Long,
ByVal dwFlagsAndAttributes As Long,
ByVal hTemplateFile As Long) As Long
Declare Function WriteFile Lib "kernel32"
(ByVal hFile As Long,
lpBuffer As Any,
ByVal nNumberOfBytesToWrite As Long,
lpNumberOfBytesWritten As Long,
lpOverlapped As OVERLAPPED) As Long
Declare Function ReadFile Lib "kernel32"
(ByVal hFile As Long,
lpBuffer As Any,
ByVal nNumberOfBytesToRead As Long,
lpNumberOfBytesRead As Long,
lpOverlapped As OVERLAPPED) As Long
Declare Function CloseHandle Lib "kernel32"
(ByVal hObject As Long) As Long
Public Const GENERIC_READ = &H80000000
Public Const GENERIC_WRITE = &H40000000
Public Const OPEN_EXISTING = 3
Public Const FILE_FLAG_OVERLAPPED = &H40000000
'********************
Type OVERLAPPED
Internal As Long
InternalHigh As Long
offset As Long
OffsetHigh As Long
hEvent As Long
End Type
All'inerno dell'onclick del bottone ci emtti questa roba :
Codice:
Dim hFile As Long
Dim ret As Long
Dim number As Long
number = 0
hFile=CreateFile("LPT1", GENERIC_READ Or GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0)
If hFile <> INVALID_HANDLE_VALUE Then
ret = WriteFile(hFile, "Ciao", 4, number, 0)
CloseHandle(hFile)
End If
Comunque non lo posso provare...