-
Usb detection
[Resolved]
I need to detect the usb using the vb....
Here is my code that gets me to DBT_DEVNODES_CHANGED:
*************************************************
Private Sub Form_Load()
SetWindowLong hwnd, GWL_WNDPROC, AddressOf MyWindowProc
End Sub
*************************************************
Public Function MyWindowProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Debug.Print "WM_DEVICECHANGE " & WM_DEVICECHANGE
If Msg = WM_DEVICECHANGE Then
Debug.Print "wParam " & wParam
Select Case wParam
Case &H8000&
Call Form1.DeviceArrival
Case &H8004&
Call Form1.DeviceRemoveComplete
Case &H7&
Dim dbHdr As DEV_BROADCAST_HDR
CopyMemory VarPtr(dbHdr), lParam, Len(dbHdr)
Debug.Print dbHdr.dbch_devicetype
If dbHdr.dbch_devicetype = DEV_BROADCAST_DEVICEINTERFACE Then
Dim dbDdb As DEV_BROADCAST_DEVICEINTERFACE
CopyMemory VarPtr(dbDdb), lParam, Len(dbDdb)
MsgBox dbDdb.dbcc_name
End If
End Select
MyWindowProc = 0
Exit Function
End If
MyWindowProc = CallWindowProc(glngPrevWndProc, hwnd, Msg, wParam, lParam)
End Function
*************************************************
I have the API reference in the module
Declare Sub RegisterDeviceNotification Lib "user32.dll" _
Alias "RegisterDeviceNotificationA" ( _
ByVal hRecipient As Long, _
NotificationFilter As Any, _
ByVal Flags As Long)
*************************************************
I am getting error msg in form load ( invalid use of addressof operator )
please help... Thanks in advance
-
Re: Usb detection
Move your MyWindowProc function into your code module.
-
Re: Usb detection
thanks for your reply... its already there only
-
Re: Usb detection
-
Re: Usb detection
-
Re: Usb detection
hello dee-u! thank you dude.... this what i expect... once again thanks for the links....
-
Re: Usb detection
No problem. You can now mark this thread as resolved using the Thread Tools menu.