home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / dbt.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  15KB  |  456 lines

  1. /*****************************************************************************
  2.  *
  3.  *  (C) Copyright 1993 - 1998 Microsoft Corporation
  4.  *
  5.  *  Title:      DBT.H - Equates for WM_DEVICECHANGE and BroadcastSystemMessage
  6.  *
  7.  *  Version:    4.00
  8.  *
  9.  *  Date:       24-May-1993
  10.  *
  11.  *  Author:     rjc
  12.  *
  13.  *----------------------------------------------------------------------------
  14.  *
  15.  *  Change log:
  16.  *
  17.  *     DATE     REV                 DESCRIPTION
  18.  *  ----------- --- ----------------------------------------------------------
  19.  *
  20.  *****************************************************************************/
  21.  
  22. #ifndef _DBT_H
  23. #define _DBT_H
  24.  
  25. /*
  26.  * BroadcastSpecialMessage constants.
  27.  */
  28. #define WM_DEVICECHANGE         0x0219
  29.  
  30. /* XLATOFF */
  31. #ifdef  IS_32
  32. #define DBTFAR
  33. #else
  34. #define DBTFAR  far
  35. #endif
  36. /* XLATON */
  37.  
  38. #ifndef _WCHAR_T_DEFINED
  39. typedef unsigned short wchar_t;
  40. #define _WCHAR_T_DEFINED
  41. #endif
  42.  
  43. #ifndef GUID_DEFINED
  44.     #define GUID_DEFINED
  45.     typedef struct _GUID {
  46.         ULONG   Data1;
  47.         unsigned short Data2;
  48.         unsigned short Data3;
  49.         unsigned char Data4[8];
  50.     } GUID;
  51. #endif // !defined(GUID_DEFINED)
  52.  
  53. /*
  54.  * Broadcast message and receipient flags.
  55.  *
  56.  * Note that there is a third "flag". If the wParam has:
  57.  *
  58.  * bit 15 on:   lparam is a pointer and bit 14 is meaningfull.
  59.  * bit 15 off:  lparam is just a UNLONG data type.
  60.  *
  61.  * bit 14 on:   lparam is a pointer to an ASCIIZ string.
  62.  * bit 14 off:  lparam is a pointer to a binary struture starting with
  63.  *              a dword describing the length of the structure.
  64.  */
  65. #define BSF_QUERY               0x00000001
  66. #define BSF_IGNORECURRENTTASK   0x00000002      /* Meaningless for VxDs */
  67. #define BSF_FLUSHDISK           0x00000004      /* Shouldn't be used by VxDs */
  68. #define BSF_NOHANG              0x00000008
  69. #define BSF_POSTMESSAGE         0x00000010
  70. #define BSF_FORCEIFHUNG         0x00000020
  71. #define BSF_NOTIMEOUTIFNOTHUNG  0x00000040
  72. #define BSF_MSGSRV32ISOK        0x80000000      /* Called synchronously from PM API */
  73. #define BSF_MSGSRV32ISOK_BIT    31              /* Called synchronously from PM API */
  74.  
  75. #define BSM_ALLCOMPONENTS       0x00000000
  76. #define BSM_VXDS                0x00000001
  77. #define BSM_NETDRIVER           0x00000002
  78. #define BSM_INSTALLABLEDRIVERS  0x00000004
  79. #define BSM_APPLICATIONS        0x00000008
  80.  
  81. /*
  82.  * Message = WM_DEVICECHANGE
  83.  * wParam  = DBT_APPYBEGIN
  84.  * lParam  = (not used)
  85.  *
  86.  *      'Appy-time is now available.  This message is itself sent
  87.  *      at 'Appy-time.
  88.  *
  89.  * Message = WM_DEVICECHANGE
  90.  * wParam  = DBT_APPYEND
  91.  * lParam  = (not used)
  92.  *
  93.  *      'Appy-time is no longer available.  This message is *NOT* sent
  94.  *      at 'Appy-time.  (It cannot be, because 'Appy-time is gone.)
  95.  *
  96.  * NOTE!  It is possible for DBT_APPYBEGIN and DBT_APPYEND to be sent
  97.  * multiple times during a single Windows session.  Each appearance of
  98.  * 'Appy-time is bracketed by these two messages, but 'Appy-time may
  99.  * momentarily become unavailable during otherwise normal Windows
  100.  * processing.  The current status of 'Appy-time availability can always
  101.  * be obtained from a call to _SHELL_QueryAppyTimeAvailable.
  102.  */
  103. #define DBT_APPYBEGIN                   0x0000
  104. #define DBT_APPYEND                     0x0001
  105.  
  106. /*
  107.  * Message = WM_DEVICECHANGE
  108.  * wParam  = DBT_DEVNODES_CHANGED
  109.  * lParam  = 0
  110.  *
  111.  *      send when configmg finished a process tree batch. Some devnodes
  112.  *      may have been added or removed. This is used by ring3 people which
  113.  *      need to be refreshed whenever any devnode changed occur (like
  114.  *      device manager). People specific to certain devices should use
  115.  *      DBT_DEVICE* instead.
  116.  */
  117.  
  118. #define DBT_DEVNODES_CHANGED            0x0007
  119.  
  120. /*
  121.  * Message = WM_DEVICECHANGE
  122.  * wParam  = DBT_QUERYCHANGECONFIG
  123.  * lParam  = 0
  124.  *
  125.  *      sent to ask if a config change is allowed
  126.  */
  127.  
  128. #define DBT_QUERYCHANGECONFIG           0x0017
  129.  
  130. /*
  131.  * Message = WM_DEVICECHANGE
  132.  * wParam  = DBT_CONFIGCHANGED
  133.  * lParam  = 0
  134.  *
  135.  *      sent when a config has changed
  136.  */
  137.  
  138. #define DBT_CONFIGCHANGED               0x0018
  139.  
  140. /*
  141.  * Message = WM_DEVICECHANGE
  142.  * wParam  = DBT_CONFIGCHANGECANCELED
  143.  * lParam  = 0
  144.  *
  145.  *      someone cancelled the config change
  146.  */
  147.  
  148. #define DBT_CONFIGCHANGECANCELED        0x0019
  149.  
  150. /*
  151.  * Message = WM_DEVICECHANGE
  152.  * wParam  = DBT_MONITORCHANGE
  153.  * lParam  = new resolution to use (LOWORD=x, HIWORD=y)
  154.  *           if 0, use the default res for current config
  155.  *
  156.  *      this message is sent when the display monitor has changed
  157.  *      and the system should change the display mode to match it.
  158.  */
  159.  
  160. #define DBT_MONITORCHANGE               0x001B
  161.  
  162. /*
  163.  * Message = WM_DEVICECHANGE
  164.  * wParam  = DBT_SHELLLOGGEDON
  165.  * lParam  = 0
  166.  *
  167.  *      The shell has finished login on: VxD can now do Shell_EXEC.
  168.  */
  169.  
  170. #define DBT_SHELLLOGGEDON               0x0020
  171.  
  172. /*
  173.  * Message = WM_DEVICECHANGE
  174.  * wParam  = DBT_CONFIGMGAPI
  175.  * lParam  = CONFIGMG API Packet
  176.  *
  177.  *      CONFIGMG ring 3 call.
  178.  */
  179. #define DBT_CONFIGMGAPI32               0x0022
  180.  
  181. /*
  182.  * Message = WM_DEVICECHANGE
  183.  * wParam  = DBT_VXDINITCOMPLETE
  184.  * lParam  = 0
  185.  *
  186.  *      CONFIGMG ring 3 call.
  187.  */
  188. #define DBT_VXDINITCOMPLETE             0x0023
  189.  
  190. /*
  191.  * Message = WM_DEVICECHANGE
  192.  * wParam  = DBT_VOLLOCK*
  193.  * lParam  = pointer to VolLockBroadcast structure described below
  194.  *
  195.  *      Messages issued by IFSMGR for volume locking purposes on WM_DEVICECHANGE.
  196.  *      All these messages pass a pointer to a struct which has no pointers.
  197.  */
  198.  
  199. #define DBT_VOLLOCKQUERYLOCK    0x8041
  200. #define DBT_VOLLOCKLOCKTAKEN    0x8042
  201. #define DBT_VOLLOCKLOCKFAILED   0x8043
  202. #define DBT_VOLLOCKQUERYUNLOCK  0x8044
  203. #define DBT_VOLLOCKLOCKRELEASED 0x8045
  204. #define DBT_VOLLOCKUNLOCKFAILED 0x8046
  205.  
  206. /*
  207.  * Device broadcast header
  208.  */
  209.  
  210. struct _DEV_BROADCAST_HDR {     /* */
  211.     DWORD       dbch_size;
  212.     DWORD       dbch_devicetype;
  213.     DWORD       dbch_reserved;
  214. };
  215.  
  216. typedef struct  _DEV_BROADCAST_HDR      DEV_BROADCAST_HDR;
  217. typedef         DEV_BROADCAST_HDR       DBTFAR *PDEV_BROADCAST_HDR;
  218.  
  219. /*
  220.  * Structure for volume lock broadcast
  221.  */
  222.  
  223. typedef struct VolLockBroadcast VolLockBroadcast;
  224. typedef VolLockBroadcast *pVolLockBroadcast;
  225. struct VolLockBroadcast {
  226.         struct  _DEV_BROADCAST_HDR vlb_dbh;
  227.         DWORD   vlb_owner;              // thread on which lock request is being issued
  228.         BYTE    vlb_perms;              // lock permission flags defined below
  229.         BYTE    vlb_lockType;           // type of lock
  230.         BYTE    vlb_drive;              // drive on which lock is issued
  231.         BYTE    vlb_flags;              // miscellaneous flags
  232. };
  233.  
  234. /*
  235.  * Values for vlb_perms
  236.  */
  237. #define LOCKP_ALLOW_WRITES              0x01    // Bit 0 set - allow writes
  238. #define LOCKP_FAIL_WRITES               0x00    // Bit 0 clear - fail writes
  239. #define LOCKP_FAIL_MEM_MAPPING          0x02    // Bit 1 set - fail memory mappings
  240. #define LOCKP_ALLOW_MEM_MAPPING         0x00    // Bit 1 clear - allow memory mappings
  241. #define LOCKP_USER_MASK                 0x03    // Mask for user lock flags
  242. #define LOCKP_LOCK_FOR_FORMAT           0x04    // Level 0 lock for format
  243.  
  244. /*
  245.  * Values for vlb_flags
  246.  */
  247. #define LOCKF_LOGICAL_LOCK              0x00    // Bit 0 clear - logical lock
  248. #define LOCKF_PHYSICAL_LOCK             0x01    // Bit 0 set - physical lock
  249.  
  250. /*
  251.  * Message = WM_DEVICECHANGE
  252.  * wParam  = DBT_NODISKSPACE
  253.  * lParam  = drive number of drive that is out of disk space (1-based)
  254.  *
  255.  * Message issued by IFS manager when it detects that a drive is run out of
  256.  * free space.
  257.  */
  258.  
  259. #define DBT_NO_DISK_SPACE               0x0047
  260.  
  261. /*
  262.  * Message = WM_DEVICECHANGE
  263.  * wParam  = DBT_LOW_DISK_SPACE
  264.  * lParam  = drive number of drive that is low on disk space (1-based)
  265.  *
  266.  * Message issued by VFAT when it detects that a drive it has mounted
  267.  * has the remaning free space below a threshold specified by the
  268.  * registry or by a disk space management application.
  269.  * The broadcast is issued by VFAT ONLY when space is either allocated
  270.  * or freed by VFAT.
  271.  */
  272.  
  273. #define DBT_LOW_DISK_SPACE      0x0048
  274.  
  275. #define DBT_CONFIGMGPRIVATE             0x7FFF
  276.  
  277. /*
  278.  * The following messages are for WM_DEVICECHANGE. The immediate list
  279.  * is for the wParam. ALL THESE MESSAGES PASS A POINTER TO A STRUCT
  280.  * STARTING WITH A DWORD SIZE AND HAVING NO POINTER IN THE STRUCT.
  281.  *
  282.  */
  283. #define DBT_DEVICEARRIVAL               0x8000  // system detected a new device
  284. #define DBT_DEVICEQUERYREMOVE           0x8001  // wants to remove, may fail
  285. #define DBT_DEVICEQUERYREMOVEFAILED     0x8002  // removal aborted
  286. #define DBT_DEVICEREMOVEPENDING         0x8003  // about to remove, still avail.
  287. #define DBT_DEVICEREMOVECOMPLETE        0x8004  // device is gone
  288. #define DBT_DEVICETYPESPECIFIC          0x8005  // type specific event
  289. #if(WINVER >= 0x040A)
  290. #define DBT_CUSTOMEVENT                 0x8006  // user-defined event
  291. #endif /* WINVER >= 0x040A */
  292.  
  293. #define DBT_DEVTYP_OEM                  0x00000000  // oem-defined device type
  294. #define DBT_DEVTYP_DEVNODE              0x00000001  // devnode number
  295. #define DBT_DEVTYP_VOLUME               0x00000002  // logical volume
  296. #define DBT_DEVTYP_PORT                 0x00000003  // serial, parallel
  297. #define DBT_DEVTYP_NET                  0x00000004  // network resource
  298.  
  299. #if(WINVER >= 0x040A)
  300. #define DBT_DEVTYP_DEVICEINTERFACE      0x00000005  // device interface class
  301. #define DBT_DEVTYP_HANDLE               0x00000006  // file system handle
  302. #endif /* WINVER >= 0x040A */
  303.  
  304. struct _DEV_BROADCAST_HEADER { /* */
  305.     DWORD       dbcd_size;
  306.     DWORD       dbcd_devicetype;
  307.     DWORD       dbcd_reserved;
  308. };
  309.  
  310. struct _DEV_BROADCAST_OEM {     /* */
  311.     DWORD       dbco_size;
  312.     DWORD       dbco_devicetype;
  313.     DWORD       dbco_reserved;
  314.     DWORD       dbco_identifier;
  315.     DWORD       dbco_suppfunc;
  316. };
  317.  
  318. typedef struct  _DEV_BROADCAST_OEM      DEV_BROADCAST_OEM;
  319. typedef         DEV_BROADCAST_OEM       DBTFAR *PDEV_BROADCAST_OEM;
  320.  
  321. struct _DEV_BROADCAST_DEVNODE { /* */
  322.     DWORD       dbcd_size;
  323.     DWORD       dbcd_devicetype;
  324.     DWORD       dbcd_reserved;
  325.     DWORD       dbcd_devnode;
  326. };
  327.  
  328. typedef struct  _DEV_BROADCAST_DEVNODE  DEV_BROADCAST_DEVNODE;
  329. typedef         DEV_BROADCAST_DEVNODE   DBTFAR *PDEV_BROADCAST_DEVNODE;
  330.  
  331. struct _DEV_BROADCAST_VOLUME { /* */
  332.     DWORD       dbcv_size;
  333.     DWORD       dbcv_devicetype;
  334.     DWORD       dbcv_reserved;
  335.     DWORD       dbcv_unitmask;
  336.     WORD        dbcv_flags;
  337. };
  338.  
  339. typedef struct  _DEV_BROADCAST_VOLUME   DEV_BROADCAST_VOLUME;
  340. typedef         DEV_BROADCAST_VOLUME    DBTFAR *PDEV_BROADCAST_VOLUME;
  341.  
  342. #define DBTF_MEDIA      0x0001          // media comings and goings
  343. #define DBTF_NET        0x0002          // network volume
  344.  
  345. typedef struct _DEV_BROADCAST_PORT_A {
  346.     DWORD       dbcp_size;
  347.     DWORD       dbcp_devicetype;
  348.     DWORD       dbcp_reserved;
  349.     char        dbcp_name[1];
  350. } DEV_BROADCAST_PORT_A, *PDEV_BROADCAST_PORT_A;
  351.  
  352. typedef struct _DEV_BROADCAST_PORT_W {
  353.     DWORD       dbcp_size;
  354.     DWORD       dbcp_devicetype;
  355.     DWORD       dbcp_reserved;
  356.     wchar_t     dbcp_name[1];
  357. } DEV_BROADCAST_PORT_W, DBTFAR *PDEV_BROADCAST_PORT_W;
  358.  
  359. #ifdef UNICODE
  360. typedef DEV_BROADCAST_PORT_W     DEV_BROADCAST_PORT;
  361. typedef PDEV_BROADCAST_PORT_W    PDEV_BROADCAST_PORT;
  362. #else
  363. typedef DEV_BROADCAST_PORT_A     DEV_BROADCAST_PORT;
  364. typedef PDEV_BROADCAST_PORT_A    PDEV_BROADCAST_PORT;
  365. #endif
  366.  
  367. struct _DEV_BROADCAST_NET { /* */
  368.     DWORD       dbcn_size;
  369.     DWORD       dbcn_devicetype;
  370.     DWORD       dbcn_reserved;
  371.     DWORD       dbcn_resource;
  372.     DWORD       dbcn_flags;
  373. };
  374.  
  375. typedef struct  _DEV_BROADCAST_NET      DEV_BROADCAST_NET;
  376. typedef         DEV_BROADCAST_NET       DBTFAR *PDEV_BROADCAST_NET;
  377.  
  378. #if(WINVER >= 0x040A)
  379.  
  380. typedef struct _DEV_BROADCAST_DEVICEINTERFACE_A {
  381.     DWORD       dbcc_size;
  382.     DWORD       dbcc_devicetype;
  383.     DWORD       dbcc_reserved;
  384.     GUID        dbcc_classguid;
  385.     char        dbcc_name[1];
  386. } DEV_BROADCAST_DEVICEINTERFACE_A, *PDEV_BROADCAST_DEVICEINTERFACE_A;
  387.  
  388. typedef struct _DEV_BROADCAST_DEVICEINTERFACE_W {
  389.     DWORD       dbcc_size;
  390.     DWORD       dbcc_devicetype;
  391.     DWORD       dbcc_reserved;
  392.     GUID        dbcc_classguid;
  393.     wchar_t     dbcc_name[1];
  394. } DEV_BROADCAST_DEVICEINTERFACE_W, *PDEV_BROADCAST_DEVICEINTERFACE_W;
  395.  
  396. #ifdef UNICODE
  397. typedef DEV_BROADCAST_DEVICEINTERFACE_W   DEV_BROADCAST_DEVICEINTERFACE;
  398. typedef PDEV_BROADCAST_DEVICEINTERFACE_W  PDEV_BROADCAST_DEVICEINTERFACE;
  399. #else
  400. typedef DEV_BROADCAST_DEVICEINTERFACE_A   DEV_BROADCAST_DEVICEINTERFACE;
  401. typedef PDEV_BROADCAST_DEVICEINTERFACE_A  PDEV_BROADCAST_DEVICEINTERFACE;
  402. #endif
  403.  
  404. typedef struct _DEV_BROADCAST_HANDLE {
  405.     DWORD       dbch_size;
  406.     DWORD       dbch_devicetype;
  407.     DWORD       dbch_reserved;
  408.     HANDLE      dbch_handle;     // file handle used in call to RegisterDeviceNotification
  409.     DWORD       dbch_hdevnotify; // HDEVNOTIFY returned from RegisterDeviceNotification
  410.     //
  411.     // The following 3 fields are only valid if wParam is DBT_CUSTOMEVENT.
  412.     //
  413.     GUID        dbch_eventguid;
  414.     LONG        dbch_nameoffset; // offset (bytes) of variable-length string buffer (-1 if none)
  415.     BYTE        dbch_data[1];    // variable-sized buffer, potentially containing binary and/or text data
  416. } DEV_BROADCAST_HANDLE, *PDEV_BROADCAST_HANDLE;
  417.  
  418. #endif /* WINVER >= 0x040A */
  419.  
  420. #define DBTF_RESOURCE   0x00000001      // network resource
  421. #define DBTF_XPORT      0x00000002      // new transport coming or going
  422. #define DBTF_SLOWNET    0x00000004      // new incoming transport is slow
  423.                                         // (dbcn_resource undefined for now)
  424.  
  425. #define DBT_VPOWERDAPI  0x8100          // VPOWERD API for Win95
  426.  
  427. /*
  428.  *  User-defined message types all use wParam = 0xFFFF with the
  429.  *  lParam a pointer to the structure below.
  430.  *
  431.  *  dbud_dbh - DEV_BROADCAST_HEADER must be filled in as usual.
  432.  *
  433.  *  dbud_szName contains a case-sensitive ASCIIZ name which names the
  434.  *  message.  The message name consists of the vendor name, a backslash,
  435.  *  then arbitrary user-defined ASCIIZ text.  For example:
  436.  *
  437.  *      "WidgetWare\QueryScannerShutdown"
  438.  *      "WidgetWare\Video Q39S\AdapterReady"
  439.  *
  440.  *  After the ASCIIZ name, arbitrary information may be provided.
  441.  *  Make sure that dbud_dbh.dbch_size is big enough to encompass
  442.  *  all the data.  And remember that nothing in the structure may
  443.  *  contain pointers.
  444.  */
  445.  
  446. #define DBT_USERDEFINED 0xFFFF
  447.  
  448. struct _DEV_BROADCAST_USERDEFINED { /* */
  449.     struct _DEV_BROADCAST_HDR dbud_dbh;
  450.     char        dbud_szName[1];     /* ASCIIZ name */
  451. /*  BYTE        dbud_rgbUserDefined[];*/ /* User-defined contents */
  452. };
  453.  
  454. #endif  // _DBT_H
  455.  
  456.