Hi all,
I would like to identify if a disk is removable or fixed. I found that the relative function is "GetDriveType" but I couldn't make it work...
Thank you
Hi all,
I would like to identify if a disk is removable or fixed. I found that the relative function is "GetDriveType" but I couldn't make it work...
Thank you
Hi all,
I would like to identify if a disk is removable or fixed. I found that the relative function is "GetDriveType" but I couldn't make it work...
Thank you
Below is an example program showing how to use the GetDriveType function.
I hope it helps you.
---------------------------------------------------
IDENTIFICATION DIVISION.
PROGRAM-ID. getdrivetype.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
CRT STATUS IS CRT-STATUS
SCREEN CONTROL IS SCREEN-CONTROL
EVENT STATUS IS EVENT-STATUS.
/
WORKING-STORAGE SECTION.
01 RETURN-VALUE USAGE UNSIGNED-LONG.
01 MY-DRIVE PIC X(255) VALUE SPACES.
01 CRT-STATUS PIC 9(5).
01 SCREEN-CONTROL.
03 ACCEPT-CONTROL PIC 9.
03 CONTROL-VALUE PIC 999.
03 CONTROL-HANDLE USAGE HANDLE.
03 CONTROL-ID PIC X(2) COMP-X.
01 EVENT-STATUS.
03 EVENT-TYPE PIC X(4) COMP-X.
03 EVENT-WINDOW-HANDLE USAGE HANDLE.
03 EVENT-CONTROL-HANDLE USAGE HANDLE.
03 EVENT-CONTROL-ID PIC X(2) COMP-X.
03 EVENT-DATA-1 USAGE SIGNED-SHORT.
03 EVENT-DATA-2 USAGE SIGNED-LONG.
03 EVENT-ACTION PIC X COMP-X.
PROCEDURE DIVISION.
MAINLINE SECTION.
SET ENVIRONMENT "DLL-CONVENTION" TO 1.
CALL "KERNEL32.DLL".
MOVE "C:\\" TO MY-DRIVE.
INSPECT MY-DRIVE REPLACING TRAILING SPACES BY NULLS.
CALL "GetDriveTypeA" USING BY REFERENCE MY-DRIVE RETURNING RETURN-VALUE.
IF RETURN-VALUE = 0
DISPLAY MESSAGE BOX "The drive type cannot be determined."
TITLE "Drive Unknown"
END-IF.
IF RETURN-VALUE = 1
DISPLAY MESSAGE BOX "The root path is invalid; for example, there is "
"no volume mounted at the specified path." TITLE "Drive No Root Dir"
END-IF.
IF RETURN-VALUE = 2
DISPLAY MESSAGE BOX "The drive has removable media; for example, a "
"floppy drive, thumb drive, or flash card reader."
TITLE "Drive Removable"
END-IF.
IF RETURN-VALUE = 3
DISPLAY MESSAGE BOX "The drive has fixed media; for example, a hard "
"disk drive or flash drive." TITLE "Drive Fixed"
END-IF.
IF RETURN-VALUE = 4
DISPLAY MESSAGE BOX "The drive is a remote (network) drive."
TITLE "Drive Remote"
END-IF.
IF RETURN-VALUE = 5
DISPLAY MESSAGE BOX "The drive is a CD-ROM drive."
TITLE "Drive CD-ROM"
END-IF.
IF RETURN-VALUE = 6
DISPLAY MESSAGE BOX "The drive is a RAM disk."
TITLE "Drive RAM Disk"
END-IF.
CANCEL "KERNEL32.DLL".
ML20.
EXIT PROGRAM.
ML30.
STOP RUN.
Hi all,
I would like to identify if a disk is removable or fixed. I found that the relative function is "GetDriveType" but I couldn't make it work...
Thank you
that worked, thank you!
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.