1 /***********************************************************************\
2 *                                  dbt.d                                *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                                                                       *
6 *                 Translated from MinGW Windows headers                 *
7 *                           by Vladimir Vlasov                          *
8 *                                                                       *
9 *                       Placed into public domain                       *
10 \***********************************************************************/
11 module windows.dbt;
12 nothrow:
13 import windows.w32api, windows.windef;
14 import windows.basetyps; // for GUID
15 
16 // FIXME: clean up Windows version support
17 
18 enum : DWORD {
19 	DBT_NO_DISK_SPACE           = 0x47,
20 	DBT_CONFIGMGPRIVATE         = 0x7FFF,
21 	DBT_DEVICEARRIVAL           = 0x8000,
22 	DBT_DEVICEQUERYREMOVE       = 0x8001,
23 	DBT_DEVICEQUERYREMOVEFAILED = 0x8002,
24 	DBT_DEVICEREMOVEPENDING     = 0x8003,
25 	DBT_DEVICEREMOVECOMPLETE    = 0x8004,
26 	DBT_DEVICETYPESPECIFIC      = 0x8005,
27 	DBT_DEVTYP_OEM              = 0,
28 	DBT_DEVTYP_DEVNODE,
29 	DBT_DEVTYP_VOLUME,
30 	DBT_DEVTYP_PORT,
31 	DBT_DEVTYP_NET,
32 	DBT_DEVTYP_DEVICEINTERFACE,
33 	DBT_DEVTYP_HANDLE        // = 6
34 }
35 
36 enum : DWORD {
37 	DBT_APPYBEGIN,
38 	DBT_APPYEND,
39 	DBT_DEVNODES_CHANGED     = 7,
40 	DBT_QUERYCHANGECONFIG    = 0x17,
41 	DBT_CONFIGCHANGED        = 0x18,
42 	DBT_CONFIGCHANGECANCELED = 0x19,
43 	DBT_MONITORCHANGE        = 0x1B,
44 	DBT_SHELLLOGGEDON        = 32,
45 	DBT_CONFIGMGAPI32        = 34,
46 	DBT_VXDINITCOMPLETE      = 35,
47 	DBT_VOLLOCKQUERYLOCK     = 0x8041,
48 	DBT_VOLLOCKLOCKTAKEN     = 0x8042,
49 	DBT_VOLLOCKLOCKFAILED    = 0x8043,
50 	DBT_VOLLOCKQUERYUNLOCK   = 0x8044,
51 	DBT_VOLLOCKLOCKRELEASED  = 0x8045,
52 	DBT_VOLLOCKUNLOCKFAILED  = 0x8046,
53 	DBT_USERDEFINED          = 0xFFFF
54 }
55 
56 enum : WORD {
57 	DBTF_MEDIA = 1,
58 	DBTF_NET   = 2
59 }
60 
61 enum : DWORD {
62 	BSM_ALLCOMPONENTS      = 0,
63 	BSM_APPLICATIONS       = 8,
64 	BSM_ALLDESKTOPS        = 16,
65 	BSM_INSTALLABLEDRIVERS = 4,
66 	BSM_NETDRIVER          = 2,
67 	BSM_VXDS               = 1,
68 	BSF_FLUSHDISK          = 0x00000004,
69 	BSF_FORCEIFHUNG        = 0x00000020,
70 	BSF_IGNORECURRENTTASK  = 0x00000002,
71 	BSF_NOHANG             = 0x00000008,
72 	BSF_NOTIMEOUTIFNOTHUNG = 0x00000040,
73 	BSF_POSTMESSAGE        = 0x00000010,
74 	BSF_QUERY              = 0x00000001,
75 	BSF_MSGSRV32ISOK_BIT   = 31,
76 	BSF_MSGSRV32ISOK       = 0x80000000
77 }
78 
79 static if (_WIN32_WINNT >= 0x500) {
80 	enum : DWORD {
81 		BSF_ALLOWSFW          = 0x00000080,
82 		BSF_SENDNOTIFYMESSAGE = 0x00000100
83 	}
84 }
85 
86 static if (_WIN32_WINNT >= 0x501) {
87 	enum : DWORD {
88 		BSF_LUID        = 0x00000400,
89 		BSF_RETURNHDESK = 0x00000200
90 	}
91 }
92 
93 struct DEV_BROADCAST_HDR {
94 	DWORD dbch_size = DEV_BROADCAST_HDR.sizeof;
95 	DWORD dbch_devicetype;
96 	DWORD dbch_reserved;
97 }
98 alias DEV_BROADCAST_HDR* PDEV_BROADCAST_HDR;
99 
100 struct DEV_BROADCAST_OEM {
101 	DWORD dbco_size = DEV_BROADCAST_OEM.sizeof;
102 	DWORD dbco_devicetype;
103 	DWORD dbco_reserved;
104 	DWORD dbco_identifier;
105 	DWORD dbco_suppfunc;
106 }
107 alias DEV_BROADCAST_OEM* PDEV_BROADCAST_OEM;
108 
109 struct DEV_BROADCAST_PORT_A {
110 	DWORD dbcp_size = DEV_BROADCAST_PORT_A.sizeof;
111 	DWORD dbcp_devicetype;
112 	DWORD dbcp_reserved;
113 	char  _dbcp_name;
114 	char* dbcp_name() { return &_dbcp_name; }
115 }
116 alias DEV_BROADCAST_PORT_A* PDEV_BROADCAST_PORT_A;
117 
118 struct DEV_BROADCAST_PORT_W {
119 	DWORD  dbcp_size = DEV_BROADCAST_PORT_W.sizeof;
120 	DWORD  dbcp_devicetype;
121 	DWORD  dbcp_reserved;
122 	WCHAR  _dbcp_name;
123 	WCHAR* dbcp_name() { return &_dbcp_name; }
124 }
125 alias DEV_BROADCAST_PORT_W* PDEV_BROADCAST_PORT_W;
126 
127 struct DEV_BROADCAST_USERDEFINED {
128 	DEV_BROADCAST_HDR dbud_dbh;
129 	char  _dbud_szName;
130 	char* dbud_szName() { return &_dbud_szName; }
131 }
132 
133 struct DEV_BROADCAST_VOLUME {
134 	DWORD dbcv_size = DEV_BROADCAST_VOLUME.sizeof;
135 	DWORD dbcv_devicetype;
136 	DWORD dbcv_reserved;
137 	DWORD dbcv_unitmask;
138 	WORD  dbcv_flags;
139 }
140 alias DEV_BROADCAST_VOLUME* PDEV_BROADCAST_VOLUME;
141 
142 version (Unicode) {
143 	alias DEV_BROADCAST_PORT_W DEV_BROADCAST_PORT;
144 } else {
145 	alias DEV_BROADCAST_PORT_A DEV_BROADCAST_PORT;
146 }
147 alias DEV_BROADCAST_PORT* PDEV_BROADCAST_PORT;
148 
149 static if (_WIN32_WINNT >= 0x500) {
150 	struct DEV_BROADCAST_DEVICEINTERFACE_A {
151 		DWORD dbcc_size = DEV_BROADCAST_DEVICEINTERFACE_A.sizeof;
152 		DWORD dbcc_devicetype;
153 		DWORD dbcc_reserved;
154 		GUID  dbcc_classguid;
155 		char  _dbcc_name;
156 		char* dbcc_name() { return &_dbcc_name; }
157 	}
158 	alias DEV_BROADCAST_DEVICEINTERFACE_A* PDEV_BROADCAST_DEVICEINTERFACE_A;
159 
160 	struct DEV_BROADCAST_DEVICEINTERFACE_W {
161 		DWORD  dbcc_size = DEV_BROADCAST_DEVICEINTERFACE_W.sizeof;
162 		DWORD  dbcc_devicetype;
163 		DWORD  dbcc_reserved;
164 		GUID   dbcc_classguid;
165 		WCHAR  _dbcc_name;
166 		WCHAR* dbcc_name() { return &_dbcc_name; }
167 	}
168 	alias DEV_BROADCAST_DEVICEINTERFACE_W* PDEV_BROADCAST_DEVICEINTERFACE_W;
169 
170 	version (Unicode) {
171 		alias DEV_BROADCAST_DEVICEINTERFACE_W DEV_BROADCAST_DEVICEINTERFACE;
172 	} else {
173 		alias DEV_BROADCAST_DEVICEINTERFACE_A DEV_BROADCAST_DEVICEINTERFACE;
174 	}
175 	alias DEV_BROADCAST_DEVICEINTERFACE* PDEV_BROADCAST_DEVICEINTERFACE;
176 
177 	struct DEV_BROADCAST_HANDLE {
178 		DWORD  dbch_size = DEV_BROADCAST_HANDLE.sizeof;
179 		DWORD  dbch_devicetype;
180 		DWORD  dbch_reserved;
181 		HANDLE dbch_handle;
182 		DWORD  dbch_hdevnotify;
183 		GUID   dbch_eventguid;
184 		LONG   dbch_nameoffset;
185 		BYTE   _dbch_data;
186 		BYTE*  dbch_data() { return &_dbch_data; }
187 	}
188 	alias DEV_BROADCAST_HANDLE* PDEV_BROADCAST_HANDLE;
189 }