『第
2 楼』:
免費~~~~~~~~~~~~
// 傳入磁碟機代號 A / B / C - Z
// turbo C / Borland C 寫法
long GetDiskSerial(char driver)
{
union REGS regs;
struct SREGS sregs;
struct DISK
{
unsigned code;
long serial;
char volume[11];
char type[8];
} SERIAL;
regs.h.ah =0x69;
regs.h.al =0x00;
regs.h.bl =toupper(driver)-'A'+1;
regs.x.dx =FP_OFF(&SERIAL);
sregs.ds =FP_SEG(&SERIAL);
intdosx(®s,®s,&sregs);
if(regs.x.cflag==0) return(SERIAL.serial); else return(0);
}
// 傳入磁碟機代號 A / B / C - Z
// WINDOWS 下 MINGW32 寫法
DWORD GetDiskSerial(char driver)
{
char lpRootPathName[256];
char lpVolumeNameBuffer[256];
DWORD nVolumeNameSize=256;
DWORD lpVolumeSerialNumber;
DWORD lpMaximumComponentLength;
DWORD lpFileSystemFlags;
char lpFileSystemNameBuffer[256];
DWORD nFileSystemNameSize=256;
sprintf(lpRootPathName, "%c:\\", driver);
GetVolumeInformation(
lpRootPathName,
lpVolumeNameBuffer,
nVolumeNameSize,
&lpVolumeSerialNumber,
&lpMaximumComponentLength,
&lpFileSystemFlags,
lpFileSystemNameBuffer,
nFileSystemNameSize );
return(lpVolumeSerialNumber);
}
// 傳入磁碟機代號 A / B / C - Z
// DOS 下 DJGPP 寫法
DWORD GetDiskSerial(char driver)
{
__dpmi_regs regs;
char Buffer[30];
char *ts, *ss;
unsigned Serial;
if(driver<'A' || driver>'Z') return(0);
regs.h.ah =0x69;
regs.h.al =0x00;
regs.h.bl =driver-'A'+1;
regs.x.ds =__tb >> 4;
regs.x.dx =__tb & 0x0f;
__dpmi_int (0x21, ®s);
if(regs.x.flags & 1) return(0);
dosmemget (__tb, 30, &Buffer);
ts = &Buffer[2];
ss = (char *)&Serial;
*ss++ = *ts++;
*ss++ = *ts++;
*ss++ = *ts++;
*ss++ = *ts++;
return(Serial);
}
|