Results 1 to 7 of 7

Thread: Usb detection

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2008
    Location
    XP & Vista
    Posts
    181

    Resolved 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
    Last edited by kpmsivachand; Dec 20th, 2008 at 11:00 PM.

  2. #2
    Addicted Member pcuser's Avatar
    Join Date
    Jun 2008
    Posts
    219

    Re: Usb detection

    Move your MyWindowProc function into your code module.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2008
    Location
    XP & Vista
    Posts
    181

    Re: Usb detection

    thanks for your reply... its already there only

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 2008
    Location
    XP & Vista
    Posts
    181

    Re: Usb detection

    Guys anyone help me...

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Usb detection

    I hope this helps.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Feb 2008
    Location
    XP & Vista
    Posts
    181

    Re: Usb detection

    hello dee-u! thank you dude.... this what i expect... once again thanks for the links....

  7. #7
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Usb detection

    No problem. You can now mark this thread as resolved using the Thread Tools menu.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width