HOWTO: Programmatically Undock Using the Keyboard Buffer

Last reviewed: June 5, 1997
Article ID: Q169588
The information in this article applies to:
  • Windows 95 Device Driver Kit (DDK), version 4.0
  • Microsoft Win32 Software Development Kit (SDK)

SUMMARY

Windows 95 does not support a direct API to programmatically undock a laptop computer. However, you can undock the laptop by sending the appropriate keystroke sequence for the machine to the keyboard buffer.

MORE INFORMATION

From a VxD, you can use VKD_Force_Keys to force scan codes into the keyboard buffer just as if they had been typed on the physical keyboard. These keys are processed in the context of the focus virtual machine.

From an application, you can use the keybd_event function to synthesize the appropriate keystrokes to undock a laptop. The code below sends a CTRL ESC sequence:

      #include <windows.h>

      main()
      {
          keybd_event( VK_CONTROL,0x9d, KEYEVENTF_EXTENDEDKEY | 0, 0);
          keybd_event( VK_ESCAPE,0x81, KEYEVENTF_EXTENDEDKEY | 0, 0 );
          keybd_event( VK_ESCAPE,0x81, KEYEVENTF_EXTENDEDKEY |
   KEYEVENTF_KEYUP,0 );
          keybd_event( VK_CONTROL,0x9d, KEYEVENTF_EXTENDEDKEY |
   KEYEVENTF_KEYUP, 0 );
      }

REFERENCES

See the Windows 95 DDK for more information on VKD_Force_Keys. See the Win32 SDK for more information on keybd_event.


Keywords : kbhowto
Version : 4.0
Platform : NT WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 5, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.