Hello, Brother Guo!
The program has been tested, and the menu functions are very easy to use. Thank you! :-)
Regarding the program to judge the floppy disk or USB flash drive, I will copy the segment of program I used before, hoping it can be a little help to Brother Guo:
Use the absread function to judge whether the USB flash drive ("D:") exists; (the hidden part is the program judged by _bios_disk):
BOOL IfUsbExist()
{//Judge whether the floppy disk exists
char buffer[512];
char ch[MAXPATH], ch1[50];
int Ifdrive = -1;
UINT nRetry;
char USBPATH[10];
strcpy(USBPATH, "D:"); //The D drive is the USB flash drive
char cDrive = toupper(USBPATH[0]) - 'A';
//struct diskinfo_t di;
//di.drive = toupper(USBPATH[0]) - 'C' + 0x80; //D drive USB
//di.head = 0;
//di.track = 0;
//di.sector = 1;
//di.nsectors = 1;
//di.buffer = buffer;
memset(buffer, 0, 512);
Ifdrive = absread(cDrive, 1, 2, buffer); //Re_bios_disk(_DISK_READ, &di);
//No USB flash drive
if (Ifdrive!= 0) return FALSE;
return TRUE;
}
BOOL IfFloppyExist()
{//Judge whether the floppy disk exists
char buffer[512];
struct diskinfo_t di;
int Ifdrive = -1;
char ch[MAXPATH], ch1[50];
UINT nRetry;
char FLOPPYPATH[10];
strcpy(FLOPPYPATH, "A:"); //The floppy disk is the A drive
memset(buffer, 0, 512);
strcpy(ch, FLOPPYPATH);
di.drive = toupper(ch[0]) - 'A';
di.head = 1;
di.track = 1;
di.sector = 1;
di.nsectors = 1;
di.buffer = buffer;
Ifdrive = Re_bios_disk(_DISK_READ, &di);
//No floppy disk
if (Ifdrive != 0) return FALSE;
return TRUE;
}
UINT Re_bios_disk(unsigned cmd, struct diskinfo_t _FAR *dinfo)
{//Retry _bios_disk for 3 times to avoid noise
UINT ret;
for (char i = 0; i < 3; i++)
{
ret = _bios_disk(cmd, dinfo) & 0xff00;
if (ret == 0)
break;
}
return ret;
}