GetVolumeInformation The GetVolumeInformation function returns information about a file system and volume whose root directory is specified. BOOL GetVolumeInformation( LPCTSTR lpRootPathName, // address of root directory of the // file system LPTSTR lpVolumeNameBuffer, // address of name of the volume DWORD nVolumeNameSize, // length of lpVolumeNameBuffer LPDWORD lpVolumeSerialNumber, // address of volume serial number 此为序列号 LPDWORD lpMaximumComponentLength, // address of system's maximum // filename length LPDWORD lpFileSystemFlags, // address of file system flags LPTSTR lpFileSystemNameBuffer, // address of name of file system DWORD nFileSystemNameSize // length of lpFileSystemNameBuffer );
#include<conio.h>
#include<dos.h>
#include<ctype.h>
main()
{int i,j;
union REGS regs; struct SREGS sregs;
unsigned char ch,tp[8],id[6];
clrscr();
printf(“\n\nPlease select one operation!");
printf(“\n 0--Get disk ID
1--Set disk ID\n");
ch=getch();
if(ch==27) return 0;
printf(“\nPlease select one disk to operate.");
printf(“\n 0--Current disk
1--disk A 2--disk B 3--disk
C ...\n");
j=getch()-48;
if(ch==49)
{printf(“\nPlease enter eight
HEX numerals(such as 1f23e35b):");
/*下面这一段程序是将输入的字符串转化成相应的
十六进制数(四字节)*/
scanf(“%s",tp);
for(i=0;i<8;i++)
if(isalpha(tp[i]))
{ tp[i]=tolower(tp[i]);
tp[i]=tp[i]-87;
}
else tp[i]=tp[i]-48;
id[5]=tp[0]*16+tp[1]; id[4]=tp[2]*16+tp[3];
id[3]=tp[4]*16+tp[5]; id[2]=tp[6]*16+tp[7];
/*-------------*/
regs.h.ah=0x69; regs.h.al=0x01;
regs.h.bl=j;
regs.x.dx=FP_OFF(id);
sregs.ds=FP_SEG(id);
intdosx(&regs,&regs,&sregs);
if(regs.x.cflag==0)
printf(“This operation is successful!");
}
else
{regs.h.ah=0x69;
regs.h.al=0x00;
regs.h.bl=j;
regs.x.dx=FP_OFF(id);
sregs.ds=FP_SEG(id);
intdosx(&regs,&regs,&sregs);
if(regs.x.cflag==0)
{printf(“\nThis disk ID is ");
printf(“%x%x-%x%x\n",
id[5],id[4],id[3],id[2]);
}
else printf(“\nTo get ID is failure.\n");
}
return 0;
}
The GetVolumeInformation function returns information about a file system and volume whose root directory is specified. BOOL GetVolumeInformation(
LPCTSTR lpRootPathName, // address of root directory of the
// file system
LPTSTR lpVolumeNameBuffer, // address of name of the volume
DWORD nVolumeNameSize, // length of lpVolumeNameBuffer
LPDWORD lpVolumeSerialNumber, // address of volume serial number 此为序列号
LPDWORD lpMaximumComponentLength,
// address of system's maximum
// filename length
LPDWORD lpFileSystemFlags, // address of file system flags
LPTSTR lpFileSystemNameBuffer, // address of name of file system
DWORD nFileSystemNameSize // length of lpFileSystemNameBuffer
);