Cómo saber si el disquete está en la disquetera

Redactado por la Redacción de FoxPress basados en fuentes de diversos autores
© Copyrights 1998 by FoxPress, All rights reserved
FoxPress, Mayo 1998

Uno de los temas que más frecuentemente se suelen plantear es saber si un disco ha sido introducido en la disquetera. Para resolver esto podemos acudir a varios sistemas pero aquí comentó la forma de usarlo acudiendo al API de windows.

? ISFLOPPY("A:")


FUNCTION ISFLOPPY

LPARAMETERS rootpath
LOCAL volname,volnamelen,volserialnunber,;
	maxfilenamelen,;
	filesystemflag,filesystemname,;
	filesystemnamelen,valorretorno

DECLARE INTEGER GetVolumeInformation;
	IN win32api;
	STRING RootPath,;
	STRING @VolName,;
	INTEGER VolNameLen ,;
	INTEGER @VolSerialNumber,;
	INTEGER @MaxFileNameLen,;
	INTEGER @FileSystemFlag,;
	STRING @FileSystemName,;
	INTEGER FilesystemNameLen

rootpath="A:\"
volname=SPACE(255)
volnamelen=LEN(volname)
volserialnumber=0
maxfilenamelen=0
filesystemflag=0
filesystemname=SPACE(255)
filesystemnamelen=LEN(filesystemname)
getvolumeinformation(rootpath,@volname,;
	volnamelen,@volserialnumber,;
	@maxfilenamelen,;
	@filesystemflag,;
	@filesystemname,filesystemnamelen)

CLEAR DLLS getvolumeinformation

IF volserialnumber=0
	RETURN .F.
ELSE
	RETURN .T.
ENDIF

Por Toni Planas (SoftVic)

o también puedes usar este otro código:

destino='A:'
canal1=fcreate(destino,0)
if canal1<0
	=messagebox('Unidad no ;
		disponible',16,'¡;
 		Atención ! ')
	return
endif

Toni Atència i Puigdomènech(SoftVic)

O incluso este otro:

if not ExistDisk("A:")
	wait wind "no existe disco en la unidad"
endif

function ExistDisk
para unidad
valor = diskspace(unidad)
if valor = -1
	retu .f.
endif
retu .t.

Por Leonardo Daniel Velazquez