Everhart, Glenn From: Samuel DELPLACE [S.DELPLACE@archimed.fr] Sent: Monday, November 30, 1998 4:21 AM To: 'Marek Wierzbicki'; ntdev@atria.com Subject: RE: [ntdev] Read phisical drive I've done a such routine long time ago. I've done reverse ingenering on the boot sector of disk (the first 512 bytes) and I've found a trick to know if the disk is NTFS or FAT and to found serial number. Try this routine (It works only under NT, but the idea is the same for all OS) : DWORD GetSystemVolumeSerialNumber() { HANDLE hFile; unsigned char pBuffer[512]; DWORD dwNumberOfBytesRead; DWORD dwSerialNumber; long lLength; TCHAR sFileName[] = _T("\\.\C:"); // Open file hFile = CreateFile(sFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) return 0; // Read boot sector if (!ReadFile(hFile, pBuffer, 512, &dwNumberOfBytesRead, NULL)) { CloseHandle(hFile); return 0; } CloseHandle(hFile); // Read serial number if (pBuffer[3] == 'N') { // NTFS disk dwSerialNumber = 0; dwSerialNumber |= (DWORD)pBuffer[72]; dwSerialNumber |= (DWORD)pBuffer[73] << 8; dwSerialNumber |= (DWORD)pBuffer[74] << 16; dwSerialNumber |= (DWORD)pBuffer[75] << 24; } else { // Fat disk dwSerialNumber = 0; dwSerialNumber |= (DWORD)pBuffer[39]; dwSerialNumber |= (DWORD)pBuffer[40] << 8; dwSerialNumber |= (DWORD)pBuffer[41] << 16; dwSerialNumber |= (DWORD)pBuffer[42] << 24; } return dwSerialNumber; } ---------------------------------------------------------------- Samuel DELPLACE Software and Computer Graphics Engineer Archimed - 2 place du concert - 59800 Lille - France Tél : (33) 03 20 13 10 60 - FAX : (33) 03 20 13 10 70 Url : http://www.archimed.fr E-Mail : S.Delplace@archimed.fr ---------------------------------------------------------------- > -----Original Message----- > From: Marek Wierzbicki [SMTP:motte@polbox.com] > Sent: Sunday, November 22, 1998 10:47 AM > To: ntdev@atria.com > Subject: [ntdev] Read phisical drive > > I would like read HDD serial number using DeviceIoControl function. > If the drive is standard IDE I can do it using DFP_RECIVE_DRIVE_DATA > (0x0007c084). But if I can't read this way the number of SCSI HDD. > Mayby anybody know how can I do it? If yes what is the value of > command > (I work with Delphi, within there is no definition of IOCTL API) and > structures. > By the way, may be anybody know how can I read HDD serial number under > > WIN9x (it is harder, becouse under WIN9x not exist name > "physicalDriverX". > > Marek Wierzbicki > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > [ To unsubscribe, send email to ntdev-request@atria.com with body > UNSUBSCRIBE (the subject is ignored). ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ]