home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / dbt.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  14.7 KB  |  458 lines

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