Question : How to Receive the windows message DBT_DEVICEQUERYREMOVE

Hi!

Using Visual Basic 2005, how can i receive the windows message dbt_DeviceQueryRemove?

http://msdn2.microsoft.com/en-us/library/aa363206.aspx

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        MyBase.WndProc(m)


        If m.Msg = WM_DEVICECHANGE Then
            Select Case m.WParam.ToInt32
                Case DBT_DEVICEARRIVAL
                    RaiseEvent OnDeviceArrival(GetDriveLetter(m))
                Case DBT_DEVICEQUERYREMOVE
                    MsgBox("Yes!!!")
                Case DBT_DEVICEREMOVECOMPLETE
                    RaiseEvent OnDeviceRemove(GetDriveLetter(m))
            End Select
        End If

    End Sub

The above code does not fire DBT_DEVICEQUERYREMOVE...

Jack

Note: Please don't post any C# code. Can't understand it. :)

Answer : How to Receive the windows message DBT_DEVICEQUERYREMOVE

You must register for WM_DEVICECHANGE message by calling RegisterDeviceNotification.

Here are some vb.net examples:
http://www.dotnet247.com/247reference/msgs/41/205522.aspx
http://www.codenewsgroups.net/group/microsoft.public.vb.general.discussion/topic1379.aspx (the post on 9 Jun 2005 7:34 PM by Mike D Sutton)

Random Solutions  
 
programming4us programming4us