int biosdisk(int cmd, int drive, int head, int track, int sector, int nsects, void *buffer);
程序示例:
#include <bios.h> #include <stdio.h> int main(void) { int result; char buffer[512]; printf("Testing to see if drive a: is ready\n"); result = biosdisk(4,0,0,0,0,1,buffer); result &= 0x02; (result) ? (printf("Drive A: Ready\n")) :(printf("Drive A: Not Ready\n")); return 0; }示例2// main.c #include <stdio.h> #include <bios.h> #include "floppyio.h" int main(void) { char buf[512] = "Hello, world!"; int r; FILE *fp = fopen("booter.exe", "rb"); fread(buf, 1, 512, fp); fclose(fp); printf("floppy ready : %d\n", IsFloppyReady()); buf[510] = 0x55; buf[511] = 0xaa; printf("write: %d,%d\n", buf[510], buf[511]); r = WriteFloppyBootSection(buf); printf("r=%d\n", r); return 0; } // FloppyIO.h /* defines */ #define FLOPPY_READ 2 #define FLOPPY_WRITE 3 #define FLOPPY_READY 4 /* test if floppy is ready now, if so return 1, else 0 */ int IsFloppyReady(void); /* write first head 0 /track 0 /sector 1 of floppy disk (boot section, 512 bytes) */ int WriteFloppyBootSection(char* buffer); /* read first head 0 /track 0 /sector 1 of floppy disk (boot section, 512 bytes) */ int ReadFloppyBootSection(char* buffer); // FloppyIO.c #include "FloppyIO.h" int IsFloppyReady(void) { int result; char buffer[512]; result = biosdisk(FLOPPY_READY, 0, 0, 0, 1, 1, buffer); return ( result == 0 ? 1 : 0 ); } int WriteFloppyBootSection(char* buffer) { int result; result = biosdisk(FLOPPY_WRITE, 0, 0, 0, 1, 1, buffer); return ( result == 0 ? 1 : 0 ); } int ReadFloppyBootSection(char* buffer) { int result; result = biosdisk(FLOPPY_READ, 0, 0, 0, 1, 1, buffer); return ( result == 0 ? 1 : 0 ); }end