mov bl, Drive ;0 = default, 1 = A, 2 = B, etc.
mov ax, 4408h ;Does Device Use Removable Media
int 21h
jc error_handler ;carry set means error
cmp ax, 0 ;zero means removable media
jne not_removable
Does Device Use Removable Media (Function 4408h) determines whether the specified device contains a removable storage medium, such as a floppy disk.
Drive
Specifies the drive to check (0 = default drive, 1 = A, 2 = B, etc.).
If the function is successful, the carry flag is clear and the AX register indicates whether the storage medium in the specified drive is removable (register contains 0000h) or not (register contains 0001h).
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 |
000Fh | ERROR_INVALID_DRIVE |
Does Device Use Removable Media returns error value 0001h (ERROR_INVALID_FUNCTION) for a network drive or for a device driver that does not support the function request. In these cases, the calling program should assume that the storage medium is not removable.