亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? hidmodule.bas

?? 非常好的的USB 接口程序 基于pic單片機
?? BAS
?? 第 1 頁 / 共 2 頁
字號:
Attribute VB_Name = "HIDmodule"
'Based upon software by Jan Axelson
'http://www.lvr.com/hidpage.htm

Option Explicit

Dim bAlertable As Long
Dim Capabilities As HIDP_CAPS
Dim DataString As String
Dim DetailData As Long
Dim DetailDataBuffer() As Byte
Dim DeviceAttributes As HIDD_ATTRIBUTES
Dim DevicePathName As String
Dim DeviceInfoSet As Long
Dim ErrorString As String
Dim EventObject As Long
Public HIDHandle As Long
Dim HIDOverlapped As OVERLAPPED
Dim LastDevice As Boolean
Public MyDeviceDetected As Boolean
Dim MyDeviceInfoData As SP_DEVINFO_DATA
Dim MyDeviceInterfaceDetailData As SP_DEVICE_INTERFACE_DETAIL_DATA
Dim MyDeviceInterfaceData As SP_DEVICE_INTERFACE_DATA
Dim Needed As Long
Dim PreparsedData As Long
Public ReadHandle As Long
Dim Result As Long
Dim Security As SECURITY_ATTRIBUTES
Public Timeout As Boolean

'Set these to match the values in the device's firmware and INF file.
'0925h is Lakeview Research's vendor ID.

Const MyVendorID = &H461
Const MyProductID = &H20

Public ReadBuffer() As Byte
Public OutputReportData(31) As Byte

Function FindTheHid() As Boolean
    'Makes a series of API calls to locate the desired HID-class device.
    'Returns True if the device is detected, False if not detected.
    
    Dim Count As Integer
    Dim GUIDString As String
    Dim HidGuid As GUID
    Dim MemberIndex As Long
    
    LastDevice = False
    MyDeviceDetected = False
    
    'Values for SECURITY_ATTRIBUTES structure:
    
    Security.lpSecurityDescriptor = 0
    Security.bInheritHandle = True
    Security.nLength = Len(Security)
    
    '******************************************************************************
    'HidD_GetHidGuid
    'Get the GUID for all system HIDs.
    'Returns: the GUID in HidGuid.
    'The routine doesn't return a value in Result
    'but the routine is declared as a function for consistency with the other API calls.
    '******************************************************************************
    
    Result = HidD_GetHidGuid(HidGuid)
    Call DisplayResultOfAPICall("GetHidGuid")
    
    'Display the GUID.
    
    GUIDString = _
        Hex$(HidGuid.Data1) & "-" & _
        Hex$(HidGuid.Data2) & "-" & _
        Hex$(HidGuid.Data3) & "-"
    
    For Count = 0 To 7
    
        'Ensure that each of the 8 bytes in the GUID displays two characters.
        
        If HidGuid.Data4(Count) >= &H10 Then
            GUIDString = GUIDString & Hex$(HidGuid.Data4(Count)) & " "
        Else
            GUIDString = GUIDString & "0" & Hex$(HidGuid.Data4(Count)) & " "
        End If
    Next Count
    
    'GUID for system HIDs = GUIDString
    
    '******************************************************************************
    'SetupDiGetClassDevs
    'Returns: a handle to a device information set for all installed devices.
    'Requires: the HidGuid returned in GetHidGuid.
    '******************************************************************************
    
    DeviceInfoSet = SetupDiGetClassDevs _
        (HidGuid, _
        vbNullString, _
        0, _
        (DIGCF_PRESENT Or DIGCF_DEVICEINTERFACE))
        
    Call DisplayResultOfAPICall("SetupDiClassDevs")
    DataString = GetDataString(DeviceInfoSet, 32)
    
    '******************************************************************************
    'SetupDiEnumDeviceInterfaces
    'On return, MyDeviceInterfaceData contains the handle to a
    'SP_DEVICE_INTERFACE_DATA structure for a detected device.
    'Requires:
    'the DeviceInfoSet returned in SetupDiGetClassDevs.
    'the HidGuid returned in GetHidGuid.
    'An index to specify a device.
    '******************************************************************************
    
    'Begin with 0 and increment until no more devices are detected.
    
    MemberIndex = 0
    
    Do
        'The cbSize element of the MyDeviceInterfaceData structure must be set to
        'the structure's size in bytes. The size is 28 bytes.
        
        MyDeviceInterfaceData.cbSize = LenB(MyDeviceInterfaceData)
        Result = SetupDiEnumDeviceInterfaces _
            (DeviceInfoSet, _
            0, _
            HidGuid, _
            MemberIndex, _
            MyDeviceInterfaceData)
        
        Call DisplayResultOfAPICall("SetupDiEnumDeviceInterfaces")
        If Result = 0 Then LastDevice = True
        
        'If a device exists, display the information returned.
        
        If Result <> 0 Then
            '"  DeviceInfoSet for device #" & CStr(MemberIndex) & ": "
            '"  cbSize = " & CStr(MyDeviceInterfaceData.cbSize)
            '"  InterfaceClassGuid.Data1 = " & Hex$(MyDeviceInterfaceData.InterfaceClassGuid.Data1)
            '"  InterfaceClassGuid.Data2 = " & Hex$(MyDeviceInterfaceData.InterfaceClassGuid.Data2)
            '"  InterfaceClassGuid.Data3 = " & Hex$(MyDeviceInterfaceData.InterfaceClassGuid.Data3)
            '"  Flags = " & Hex$(MyDeviceInterfaceData.Flags)
            
            '******************************************************************************
            'SetupDiGetDeviceInterfaceDetail
            'Returns: an SP_DEVICE_INTERFACE_DETAIL_DATA structure
            'containing information about a device.
            'To retrieve the information, call this function twice.
            'The first time returns the size of the structure in Needed.
            'The second time returns a pointer to the data in DeviceInfoSet.
            'Requires:
            'A DeviceInfoSet returned by SetupDiGetClassDevs and
            'an SP_DEVICE_INTERFACE_DATA structure returned by SetupDiEnumDeviceInterfaces.
            '*******************************************************************************
            
            MyDeviceInfoData.cbSize = Len(MyDeviceInfoData)
            Result = SetupDiGetDeviceInterfaceDetail _
               (DeviceInfoSet, _
               MyDeviceInterfaceData, _
               0, _
               0, _
               Needed, _
               0)
            
            DetailData = Needed
                
            Call DisplayResultOfAPICall("SetupDiGetDeviceInterfaceDetail")
            '(OK to say too small)
            'Required buffer size for the data = Needed
            
            'Store the structure's size.
            
            MyDeviceInterfaceDetailData.cbSize = _
                Len(MyDeviceInterfaceDetailData)
            
            'Use a byte array to allocate memory for
            'the MyDeviceInterfaceDetailData structure
            
            ReDim DetailDataBuffer(Needed)
            
            'Store cbSize in the first four bytes of the array.
            
            Call RtlMoveMemory _
                (DetailDataBuffer(0), _
                MyDeviceInterfaceDetailData, _
                4)
            
            'Call SetupDiGetDeviceInterfaceDetail again.
            'This time, pass the address of the first element of DetailDataBuffer
            'and the returned required buffer size in DetailData.
            
            Result = SetupDiGetDeviceInterfaceDetail _
               (DeviceInfoSet, _
               MyDeviceInterfaceData, _
               VarPtr(DetailDataBuffer(0)), _
               DetailData, _
               Needed, _
               0)
            
            Call DisplayResultOfAPICall(" Result of second call: ")
            'MyDeviceInterfaceDetailData.cbSize = CStr(MyDeviceInterfaceDetailData.cbSize)
            
            'Convert the byte array to a string.
            
            DevicePathName = CStr(DetailDataBuffer())
            
            'Convert to Unicode.
            
            DevicePathName = StrConv(DevicePathName, vbUnicode)
            
            'Strip cbSize (4 bytes) from the beginning.
            
            DevicePathName = Right$(DevicePathName, Len(DevicePathName) - 4)
            'Device pathname = DevicePathName
                    
            '******************************************************************************
            'CreateFile
            'Returns: a handle that enables reading and writing to the device.
            'Requires:
            'The DevicePathName returned by SetupDiGetDeviceInterfaceDetail.
            '******************************************************************************
        
            HIDHandle = CreateFile _
                (DevicePathName, _
                GENERIC_READ Or GENERIC_WRITE, _
                (FILE_SHARE_READ Or FILE_SHARE_WRITE), _
                Security, _
                OPEN_EXISTING, _
                0&, _
                0)
                
            Call DisplayResultOfAPICall("CreateFile")
            'Returned handle = HIDHandle
            
            'Now we can find out if it's the device we're looking for.
            
            '******************************************************************************
            'HidD_GetAttributes
            'Requests information from the device.
            'Requires: The handle returned by CreateFile.
            'Returns: an HIDD_ATTRIBUTES structure containing
            'the Vendor ID, Product ID, and Product Version Number.
            'Use this information to determine if the detected device
            'is the one we're looking for.
            '******************************************************************************
            
            'Set the Size property to the number of bytes in the structure.
            
            DeviceAttributes.Size = LenB(DeviceAttributes)
            Result = HidD_GetAttributes _
                (HIDHandle, _
                DeviceAttributes)
                
            Call DisplayResultOfAPICall("HidD_GetAttributes")
            If Result <> 0 Then
                'HIDD_ATTRIBUTES structure filled without error.
            Else
                'Error in filling HIDD_ATTRIBUTES structure.
            End If
        
            'Structure size = DeviceAttributes.Size
            'Vendor ID = Hex$(DeviceAttributes.VendorID)
            'Product ID = Hex$(DeviceAttributes.ProductID)
            'Version Number = Hex$(DeviceAttributes.VersionNumber)
            
            'Find out if the device matches the one we're looking for.
            
            If (DeviceAttributes.VendorID = MyVendorID) And _
                (DeviceAttributes.ProductID = MyProductID) Then
                    
                    'It's the desired device.
                    
                    'My device detected
                    MyDeviceDetected = True
            Else
                    MyDeviceDetected = False
                    
                    'If it's not the one we want, close its handle.
                    Result = CloseHandle _
                        (HIDHandle)
                    DisplayResultOfAPICall ("CloseHandle")
            End If
    End If
        
        'Keep looking until we find the device or there are no more left to examine.
        
        MemberIndex = MemberIndex + 1
    Loop Until (LastDevice = True) Or (MyDeviceDetected = True)
    
    'Free the memory reserved for the DeviceInfoSet returned by SetupDiGetClassDevs.
    
    Result = SetupDiDestroyDeviceInfoList _
        (DeviceInfoSet)
    Call DisplayResultOfAPICall("DestroyDeviceInfoList")
    
    If MyDeviceDetected = True Then
        FindTheHid = True
        
        'Learn the capabilities of the device
         
         Call GetDeviceCapabilities
        
        'Get another handle for the overlapped ReadFiles.
        
        ReadHandle = CreateFile _
                (DevicePathName, _
                (GENERIC_READ Or GENERIC_WRITE), _
                (FILE_SHARE_READ Or FILE_SHARE_WRITE), _
                Security, _
                OPEN_EXISTING, _
                FILE_FLAG_OVERLAPPED, _
                0)
     
        Call DisplayResultOfAPICall("CreateFile, ReadHandle")
        'Returned handle = ReadHandle
        Call PrepareForOverlappedTransfer
    Else
        'Device not found
    End If
End Function

Private Function GetDataString _
    (Address As Long, _
    Bytes As Long) _
As String
    'Retrieves a string of length Bytes from memory, beginning at Address.
    'Adapted from Dan Appleman's "Win32 API Puzzle Book"
    
    Dim Offset As Integer
    Dim Result$
    Dim ThisByte As Byte
    
    For Offset = 0 To Bytes - 1
        Call RtlMoveMemory(ByVal VarPtr(ThisByte), ByVal Address + Offset, 1)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99久久亚洲一区二区三区青草| 中文字幕一区二区视频| 亚洲福利视频导航| 欧美日韩综合色| 视频一区国产视频| 日韩午夜中文字幕| 国产一区二区毛片| 国产精品欧美一区喷水| 91麻豆蜜桃一区二区三区| 亚洲综合色成人| 日韩三级在线观看| 成人免费av在线| 一级中文字幕一区二区| 欧美一区二区在线观看| 国产盗摄女厕一区二区三区| 亚洲日本护士毛茸茸| 欧美精品电影在线播放| 国产精品88888| 一区二区三区四区av| 欧美一级久久久| 成人av网站免费| 午夜私人影院久久久久| 久久综合久久99| 欧美影院精品一区| 精品一区二区成人精品| 国产精品夫妻自拍| 日韩女同互慰一区二区| 成人av在线电影| 另类人妖一区二区av| 最新久久zyz资源站| 欧美一区二区在线观看| av色综合久久天堂av综合| 午夜精品成人在线视频| 国产精品色眯眯| 91精品国产综合久久小美女| va亚洲va日韩不卡在线观看| 午夜电影一区二区| 国产精品国产三级国产有无不卡| 欧美日韩成人一区| 91性感美女视频| 国产高清亚洲一区| 日韩在线观看一区二区| 亚洲女同ⅹxx女同tv| 久久综合av免费| 欧美剧情片在线观看| 99视频精品全部免费在线| 精品写真视频在线观看| 日韩高清在线电影| 亚洲亚洲精品在线观看| 国产精品婷婷午夜在线观看| 欧美xxxxxxxxx| 欧美电影在哪看比较好| 色婷婷av一区二区三区之一色屋| 国产成人啪午夜精品网站男同| 奇米色777欧美一区二区| 亚洲免费视频成人| 国产精品区一区二区三| 久久精品综合网| 久久一区二区视频| 精品国产第一区二区三区观看体验 | 久久久99精品免费观看不卡| 91精品国产综合久久久久| 日本韩国精品在线| 91亚洲精品乱码久久久久久蜜桃| 国产精品66部| 丰满白嫩尤物一区二区| 韩国成人精品a∨在线观看| 蜜桃视频在线观看一区| 午夜国产精品一区| 亚洲第四色夜色| 亚洲午夜日本在线观看| 亚洲国产一区二区三区青草影视| 日韩理论片中文av| 亚洲美女屁股眼交3| 亚洲天堂2014| 亚洲男人电影天堂| 亚洲精品成人天堂一二三| 亚洲欧美在线视频观看| 亚洲天堂久久久久久久| 成人免费在线播放视频| 亚洲精品美腿丝袜| 亚洲一区二区三区四区五区黄| 亚洲影院理伦片| 日韩国产精品久久| 激情欧美日韩一区二区| 久久电影国产免费久久电影| 国产最新精品精品你懂的| 国产精品1024| 色综合天天综合网国产成人综合天 | 亚洲一区成人在线| 亚洲成人在线免费| 老司机午夜精品99久久| 精品制服美女久久| 国产一区欧美日韩| 成人av高清在线| 91黄色免费观看| 欧美一区二区在线免费观看| 久久综合久久综合久久| 国产精品电影院| 亚洲午夜久久久久| 老司机免费视频一区二区| 国产成人超碰人人澡人人澡| 色婷婷亚洲综合| 欧美成人一区二区| 国产精品久久久久毛片软件| 亚洲自拍偷拍网站| 老色鬼精品视频在线观看播放| 国产盗摄精品一区二区三区在线| 91色视频在线| 精品国产露脸精彩对白| 亚洲色图在线看| 日韩高清不卡一区二区| 国产成人丝袜美腿| 欧美日韩成人一区| 中文在线一区二区| 偷拍与自拍一区| 国产成人综合在线观看| 精品视频在线免费看| 久久男人中文字幕资源站| 一区二区三区成人| 国产麻豆一精品一av一免费| 在线亚洲人成电影网站色www| 精品国产一区久久| 樱桃国产成人精品视频| 国产综合久久久久影院| 欧美视频在线不卡| 欧美激情在线看| 秋霞av亚洲一区二区三| 色先锋资源久久综合| 久久亚洲二区三区| 亚洲va欧美va人人爽| 大桥未久av一区二区三区中文| 欧美一区二区三区在线| 最新成人av在线| 国产黄人亚洲片| 日韩免费观看高清完整版 | 日韩av一二三| 色综合天天狠狠| 国产情人综合久久777777| 亚洲国产精品一区二区www| 高清在线观看日韩| 精品久久人人做人人爽| 午夜影院久久久| 91理论电影在线观看| 国产欧美日韩视频在线观看| 奇米影视一区二区三区小说| 欧美性猛交一区二区三区精品| 成人免费在线视频| 成人看片黄a免费看在线| 久久蜜臀中文字幕| 毛片不卡一区二区| 884aa四虎影成人精品一区| 亚洲一区在线视频| 在线免费视频一区二区| 国产精品毛片大码女人| 成人午夜精品一区二区三区| 国产午夜亚洲精品午夜鲁丝片| 久久99精品久久久久久动态图| 777午夜精品免费视频| 亚洲成人三级小说| 欧美日韩一区二区在线观看视频| 亚洲私人影院在线观看| aaa亚洲精品| 亚洲色图一区二区三区| 91在线你懂得| 亚洲另类在线视频| 在线中文字幕不卡| 亚洲国产精品视频| 在线成人午夜影院| 日本伊人色综合网| 日韩一区二区三区在线观看| 久久精品国产亚洲一区二区三区| 91精品国产综合久久久蜜臀粉嫩| 日韩国产欧美一区二区三区| 日韩欧美久久一区| 国产精品系列在线观看| 国产精品久久久一本精品| av一区二区三区在线| 亚洲精品乱码久久久久久黑人| 在线观看亚洲精品| 日本女人一区二区三区| 欧美成人午夜电影| 国内精品伊人久久久久av一坑| 久久免费视频一区| 成人国产免费视频| 亚洲国产精品欧美一二99| 欧美一区二区三区日韩| 国产一区二区三区免费| ...中文天堂在线一区| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 中文字幕高清一区| 在线这里只有精品| 麻豆国产精品官网| 国产亚洲精品久| 在线免费不卡电影| 六月婷婷色综合| 亚洲日本乱码在线观看| 91精品国产综合久久精品性色| 激情丁香综合五月| 亚洲欧美日韩国产一区二区三区|