Hi,
Can anyone help me to get device serial no/ID in C, such as the serial no of HDD:IDE/SCSI, Main Board, Floppy.
Printable View
Hi,
Can anyone help me to get device serial no/ID in C, such as the serial no of HDD:IDE/SCSI, Main Board, Floppy.
Category :Windows API
Question:
How can I get volume information, such as the serial number,
from my drivers?
Answer:
procedure TForm1.Button1Click(Sender: TObject);
var
VolumeName,
FileSystemName : array [0..MAX_PATH-1] of Char;
VolumeSerialNo : DWord;
MaxComponentLength,
FileSystemFlags : Integer;
begin
GetVolumeInformation('C:\',VolumeName,MAX_PATH,@Vo lumeSerialNo,
MaxComponentLength,FileSystemFlags,
FileSystemName,MAX_PATH);
Memo1.Lines.Add('VName = '+VolumeName);
Memo1.Lines.Add('SerialNo = $'+IntToHex(VolumeSerialNo,8));
Memo1.Lines.Add('CompLen = '+IntToStr(MaxComponentLength));
Memo1.Lines.Add('Flags = $'+IntToHex(FileSystemFlags,4));
Memo1.Lines.Add('FSName = '+FileSystemName);
end;
Can anyone translate it into C?
GetVolumeInformation In
Turbo C++
Version 3.0
No function found.....
hahaha, Yeah.. fossil compiler.
What is the header file for that function ?
Do you know the library..
Anyway.. I will check your links.
Any idea on the functions? Specially for Salem.Code:
int GetIdeInfo (int Drive, unsigned int *DInfo)
{
volatile unsigned int retry;
int wordno;
/* Wait until controller is not busy */
retry = UINT_MAX;
while ((inp(0x1F7) != 0x50) && --retry);
if (!retry) return 1;
/* Get drive information */
outp(0x1F6, Drive ? 0xB0:0xA0);
outp(0x1F7, 0xEC);
/* Wait until data is available */
retry = UINT_MAX;
while ((inp(0x1F7) != 0x58) && --retry);
if (!retry) return 1;
/* Read the drive information */
for (wordno=0; wordno<256; wordno++)
DInfo[wordno] = inpw(0x1F0);
/* Return succesful */
return (0);
}
const char *ToText (const unsigned int *Data, int Start, int End)
{
static char Dest[512];
int Ctr1, Ctr2;
int i;
for (Ctr1 = Start, Ctr2 = 0; Ctr1 <= End; Ctr1++, Ctr2 += 2)
{
Dest[Ctr2+0] = (char) (Data[Ctr1] >> 8);
Dest[Ctr2+1] = (char) (Data[Ctr1] & 255);
}
Dest[Ctr2] = '\0';
for(i=strlen(Dest)-1;i>=0;i--)
if(Dest[i]==' ')
Dest[i]=0;
else
break;
return (Dest);
}
Yes, but how do you get the serial for the IDE/SCSI and Main Board?