mov bx, Drive ;0 = default, 1 = A, 2 = B, etc.
mov ch, 08h ;device category (must be 08h)
mov cl, 66h ;Get Media ID
mov dx, seg MediaID
mov ds, dx
mov dx, offset MediaID ;ds:dx points to MID structure
mov ax, 440Dh ;IOCTL for Block Device
int 21h
jc error_handler ;carry set means error
Get Media ID (Function 440Dh Minor Code 66h) returns the volume label, serial number and file system for the specified drive.
Drive
Specifies the drive for which information is to be returned (0 = default drive, 1 = A, 2 = B, etc.).
MediaID
Points to a MID structure that receives information that uniquely identifies a disk or other storage medium. The MID structure has the following form:
MID STRUC
midInfoLevel dw 0 ;information level
midSerialNum dd ? ;serial number
midVolLabel db 11 dup (?) ;ASCII volume label
midFileSysType db 8 dup (?) ;file system type
MID ENDS
For a full description of the MID structure, see Chapter 3, “File System.”
If the function is successful, the carry flag is clear, and the parameter block is filled in with information about the disk. Otherwise, the carry flag is set and the AX register contains an error value, which may be one of the following:
Value | Name |
0001h | ERROR_INVALID_FUNCTION |
0002h | ERROR_FILE_NOT_FOUND |
0005h | ERROR_ACCESS_DENIED |
Get Media ID returns 0002h (ERROR_FILE_NOT_FOUND) if the specified drive number is invalid.
Function 440Dh Minor Code 46h Set Media ID