******************************************* *** Procedur to determin drive status *** ******************************************* PROCEDURE zFlopOut PARAMETERS zDriveLetter Private all like n*, nlasterror, zFormatted, zFlopOut, zGotFiles nFiles=0 DDRIVE = SET('DEFA') zFormatted = .F. zFlopOut =.F. zGotFiles = .F. DECLARE SetErrorMode IN "kernel32.dll" INTEGER mode DECLARE INTEGER SetLastError IN "Kernel32.dll" INTEGER flags DECLARE INTEGER GetLastError IN "Kernel32.dll" DECLARE INTEGER FormatMessage IN "kernel32.dll" INTEGER flags, INTEGER; notused, INTEGER error, INTEGER locale, STRING @buffer, INTEGER bufsize,; INTEGER notused = SetLastError(0) && The this and the next are crucial to avoid = SetErrorMode(1) && the OS's fail, abort, retry dialog. zOldError = ON('ERROR') && Get existing error handler on error * && Do nothing let the system handler go nFiles = ADIR(afiles, zDriveLetter +"\*.*", 'DFL') && Try to access the drive in question release afiles && This is not needed free up resources on error &zOldError && Reset old error handler * IF nFiles = 0 nLastError = GetLastError() cError = SPACE(255) = FormatMessage( 4096, 0, nLastError, 0, @cError, 255, 0) cError = ALLTRIM(STRTRAN( cError, CHR(0))) = SetErrorMode(0) && Make sure to reset the OS error = SetLastError(0) && handler. VERY IMPORTANTE!!! * ENDIF DO CASE CASE nFiles > 0 .OR. nLastError = 18 zGotFiles = .T. zFormatted = .T. CASE nLastError = 2 zFormatted = .T. CASE nLastError = 21 zFlopOut = .T. CASE nLastError = 31 zFormatted = .F. ENDCASE RETURN( zFormatted, zFlopOut, zGotFiles )
"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams