Note that there are some explanatory texts on larger screens.

plurals
  1. POUSB Device Removal in Windows 8
    primarykey
    data
    text
    <p>I've got the following code the detect the arrival and removal of a Prolific Serial based USB Device.</p> <pre><code> protected override void WndProc(ref Message m) { DBT changeType = (DBT)m.WParam; string portName; if (m.Msg == WM_DEVICECHANGE)// &amp;&amp; changeType != DBT.OTHER) { switch (changeType) { case DBT.DEVICEREMOVAL: portName = Marshal.PtrToStringAuto((IntPtr)((long)m.LParam + 12)); // Device Removal break; case DBT.DEVICEARRIVAL: portName = Marshal.PtrToStringAuto((IntPtr)((long)m.LParam + 12)); // Device Arrival break; } } base.WndProc(ref m); } enum DBT { DEVICEARRIVAL = 0x8000, DEVICEREMOVAL = 0x8004, OTHER = 0x0007, } </code></pre> <p>My problem is that it seems as if the Removal event never gets sent in Windows 8? This code works for WinXp, Win2000, Vista &amp; Win7, perfectly.</p> <p>After monitoring the messages while plugging and removing the device, it seems as if Win8 never passes the correct removal message? </p> <p>Here are the results under Win8:</p> <p>Detection:</p> <pre><code>HWnd=1770298, LParam=0, WParam=7, Result=0, Msg=537 HWnd=1770298, LParam=98820448, WParam=32768, Result=0, Msg=537 HWnd=1770298, LParam=0, WParam=7, Result=0, Msg=537 </code></pre> <p>Removal:</p> <pre><code>HWnd=1770298, LParam=0, WParam=7, Result=0, Msg=537 </code></pre> <p>What I'm expecting:</p> <p>Detection:</p> <pre><code>HWnd=590440, LParam=0, WParam=7, Result=0, Msg=537 HWnd=590440, LParam=1241588, WParam=32768, Result=0, Msg=537 HWnd=590440, LParam=0, WParam=7, Result=0, Msg=537 </code></pre> <p>Removal:</p> <pre><code>HWnd=590440, LParam=0, WParam=7, Result=0, Msg=537 HWnd=590440, LParam=1241588, WParam=32772, Result=0, Msg=537 </code></pre> <p>This last message never arrives in Win8??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload