Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Drive status
#1
How can I get a Drive status and its type: "UNKNOWN", "READY", "NOTREADY", "INVALID".
#2
If GetDriveType returns 0, the type is unknown. If 1, it is invalid drive (does not exist).

To test ready/notready, try to find (dir) some file or folder in it.

Code:
Copy      Help
rep
,out "%i %s" WINAPI.GetDriveType("g:\") dir("g:\*" 2)
,0.5
#3
when I run

out "%i %s" WINAPI.GetDriveType("a:\") dir("a:\*" 2)

the system waits for a diskette...

How can I avoid this message?
#4
Function GetDriveStatus
Code:
Copy      Help
;/
function# $drivename ;;returns: 0 does not exist, 1 ready, 2 not ready

;EXAMPLES
;out GetDriveStatus("a:\")
;out GetDriveStatus("\\MyServer\MyShare\")



def DRIVE_UNKNOWN 0
def DRIVE_NO_ROOT_DIR 1
def DRIVE_REMOVABLE 2
def DRIVE_FIXED 3
def DRIVE_REMOTE 4
def DRIVE_CDROM 5
def DRIVE_RAMDISK 6
dll kernel32 #GetDriveType $nDrive
def SEM_FAILCRITICALERRORS  0x1
def SEM_NOGPFAULTERRORBOX  0x2
def SEM_NOOPENFILEERRORBOX  0x8000
dll kernel32 #SetErrorMode wMode
dll kernel32 #GetDiskFreeSpaceEx $lpDirectoryName LARGE_INTEGER*lpFreeBytesAvailable LARGE_INTEGER*lpTotalNumberOfBytes LARGE_INTEGER*lpTotalNumberOfFreeBytes

int i=GetDriveType(drivename)
if(i=DRIVE_NO_ROOT_DIR) ret 0

int pem=SetErrorMode(SEM_FAILCRITICALERRORS)
i=GetDiskFreeSpaceEx(drivename 0 0 0)
SetErrorMode(pem)
if(i) ret 1
ret 2
#5
Perfect.

Thanks.


Forum Jump:


Users browsing this thread: 1 Guest(s)