title: Prevent undock computer in Windows
body: <p>In Windows Vista SP2 and in Windows 7 there is a new item in the Start menu: <code>Undock computer</code>.</p>
  
  <p>In respons to the <a href="http://msdn.microsoft.com/en-us/library/aa363212(VS.85).aspx" rel="nofollow noreferrer"><code>DBT_QUERYCHANGECONFIG</code></a> event I return <code>BROADCAST_QUERY_DENY</code> but the undocking function proceeds anyway. What is wrong?</p>
  
  <p>A simple WindowProc to illustrate the problem:</p>
  
  <pre><code>LRESULT CMainWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
  {
      switch (message) {
  
          case WM_DEVICECHANGE: {
              switch (wParam) {
                  case DBT_QUERYCHANGECONFIG : {
                      return BROADCAST_QUERY_DENY;
                  }
                  break;
              }
              break;
          }
      }
      return CFrameWnd::WindowProc(message, wParam, lParam);
  }
  </code></pre>