DEV_BROADCAST_VOLUME structure
Applies to: desktop apps only
Contains information about a logical volume.
Syntax
typedef struct _DEV_BROADCAST_VOLUME {
DWORD dbcv_size;
DWORD dbcv_devicetype;
DWORD dbcv_reserved;
DWORD dbcv_unitmask;
WORD dbcv_flags;
} DEV_BROADCAST_VOLUME, *PDEV_BROADCAST_VOLUME;
Members
- dbcv_size
-
The size of this structure, in bytes.
- dbcv_devicetype
-
Set to DBT_DEVTYP_VOLUME (2).
- dbcv_reserved
-
Reserved; do not use.
- dbcv_unitmask
-
The logical unit mask identifying one or more logical units. Each bit in the mask corresponds to one logical drive. Bit 0 represents drive A, bit 1 represents drive B, and so on.
- dbcv_flags
-
This parameter can be one of the following values.
Value Meaning - DBTF_MEDIA
- 0x0001
Change affects media in drive. If not set, change affects physical device or drive.
- DBTF_NET
- 0x0002
Indicated logical volume is a network volume.
Remarks
Although the dbcv_unitmask member may specify more than one volume in any message, this does not guarantee that only one message is generated for a specified event. Multiple system features may independently generate messages for logical volumes at the same time.
Messages for media arrival and removal are sent only for media in devices that support a soft-eject mechanism. For example, applications will not see media-related volume messages for floppy disks.
Messages for network drive arrival and removal are not sent whenever network commands are issued, but rather when network connections will disappear as the result of a hardware event.
Requirements
|
Minimum supported client | Windows XP |
|---|---|
|
Minimum supported server | Windows Server 2003 |
|
Header |
|
See also
Send comments about this topic to Microsoft
Build date: 2/7/2012
{
return ((char)(Math.Log((double)unitmask, 2.0) + 65));
}
- 8/10/2011
- maklaka
private static char DriveMaskToLetter(int mask)
{
int pad = Convert.ToString(mask, 2).Length-1;
return pad < 26 && pad > 0 ? Convert.ToChar(65 + pad) : '?';
}
But this will also assume that you will only have one drive letter to return.
- 1/14/2011
- Francis Marasigan
/// <summary>
/// Gets drive letter from a bit mask where bit 0 = A, bit 1 = B etc.
/// There can actually be more than one drive in the mask but we
/// just use the last one in this case.
/// </summary>
/// <param name="mask"></param>
/// <returns></returns>
private static char DriveMaskToLetter(int mask)
{
char letter;
string drives = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// 1 = A, 2 = B, 4 = C...
int cnt = 0;
int pom = mask / 2;
while (pom != 0)
{
// while there is any bit set in the mask, shift it to the right...
pom = pom / 2;
cnt++;
}
if (cnt < drives.Length)
letter = drives[cnt];
else
letter = '?';
return letter;
}