Programar El Puerto Usb

Páginas: 4 (826 palabras) Publicado: 29 de septiembre de 2011
' This module is common to all of the Example programs
' It declares the {Open, Read, Write, Close} calls for the USB device
' These user-calls are translated into OS system calls
' This modulealso contains several support routines used by all of the examples
'
' Declare module-wide variables
Private HidHandle As Long
Public Function OpenUSBdevice(NameOfDevice$) As Boolean
' Thisfunction searches the system HID tables for NameOfDevice$
' If found then it opens the device and returns TRUE, else it returns FALSE
Dim HidGuid As Guid: Dim Success As Boolean: Dim Openned As Boolean:Dim Buffer(256) As Byte
Dim DeviceInterfaceData As Device_Interface_Data
Dim FunctionClassDeviceData As Device_Interface_Detail
'
' First, get the HID class identifier
CallHidD_GetHidGuid(HidGuid.Data(0))
' Get a handle for the Plug and Play node, request currently active HID devices
PnPHandle& = SetupDiGetClassDevs(HidGuid.Data(0), 0, 0, &H12)
If (PnPHandle& = -1) ThenErrorExit ("Could not attach to PnP node")
'
HidEntry& = 0: Openned = False
DeviceInterfaceData.cbsize = 28 'Length of data structure in bytes
' Look through the table of HID devices
Do WhileSetupDiEnumDeviceInterfaces(PnPHandle&, 0, HidGuid.Data(0), HidEntry&, DeviceInterfaceData.cbsize)
' There is a device here, get it's name
FunctionClassDeviceData.cbsize = 5
Success =SetupDiGetDeviceInterfaceDetail(PnPHandle&, DeviceInterfaceData.cbsize, _
FunctionClassDeviceData.cbsize, UBound(FunctionClassDeviceData.DataPath), BytesReturned&, 0)
If (Success = 0) ThenErrorExit ("Could not get the name of this HID device")
' Convert returned C string to Visual Basic String
hidname$ = "": i& = 0
Do While FunctionClassDeviceData.DataPath(i&) <> 0hidname$ = hidname$ & Chr$(FunctionClassDeviceData.DataPath(i&)): i& = i& + 1: Loop
' Can now open this HID device
Dim SA As Security_Attributes
HidHandle& = CreateFile(hidname$,...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Puerto usb
  • Puerto usb
  • Puerto Usb
  • Lo puerto usb
  • Programas De Usb
  • Puertos LPT USB
  • Puertos USB,HDMI,SATA
  • como bloquear los puertos usb

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS