Ver Mensaje Individual
  #2  
Antiguo 18-04-2009
Mav Mav is offline
Miembro
 
Registrado: jun 2007
Posts: 39
Reputación: 0
Mav Va por buen camino
Wink Id de hardware

Puede que te sirva esto:
Código Delphi [-]
var
query:array[0..11] of byte = (00, 00, 00, 00, 00, 00, 00, 00, 00, 08, 00, 00);
type
 Storage_Bus_Type = ( BusTypeUnknown, BusTypeScsi, BusTypeAtapi, BusTypeAta,
                     BusType1394, BusTypeSsa, BusTypeFibre, BusTypeUsb, BusTypeRAID );

type
PSTORAGE_DEVICE_DESCRIPTOR=record
Version:dword;
Size:dword;
DeviceType:UCHAR;
DeviceTypeModifier:UCHAR;
RemovableMedia:BOOLEAN;
CommandQueueing:BOOLEAN;
VendorIdOffset:dword;
ProductIdOffset:dword;
ProductRevisionOffset:dword;
SerialNumberOffset:dword;
BusType:STORAGE_BUS_TYPE;
RawPropertiesLength:dword;
RawDeviceProperties:array[1..500]of CHAR;
end;

function getValue(buf:PSTORAGE_DEVICE_DESCRIPTOR;offs:dword  ):string;
var
mas:array[0..255] of char;
begin
if offs=0 then exit;
asm
push eax
push ebx
push edx
push esi
push edi
xor edi,edi
xor esi,esi
mov esi,offs
lea edx,buf
lea ebx,mas
@m1:
mov al,[edx+esi]
mov [ebx+edi],al
inc edi
inc esi
cmp al,0
jne @m1
pop edi
pop esi
pop edx
pop ebx
pop eax
end;
result:=string(mas);
end;

function NUM(s:string):boolean;
begin
result:=true;
case s[1] of
'0'..'9','A'..'F','a'..'f':;
else result:=false;
end;
case s[2] of
'0'..'9','A'..'F','a'..'f':;
else result:=false;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
hDevice:THANDLE;
status:BOOLean;
returnedLength:ULONG;
devDescSTORAGE_DEVICE_DESCRIPTOR;
s,ss:string;
c:char;
x,y:integer;
begin
stringgrid1.Rows[stringgrid1.RowCount].Clear;
stringgrid1.Cells[0,0]:='Disk';
stringgrid1.Cells[1,0]:='VendorId';
stringgrid1.Cells[2,0]:='ProductId';
stringgrid1.Cells[3,0]:='ProductRev';
stringgrid1.Cells[4,0]:='Accommodation';
stringgrid1.Cells[5,0]:='SerialNumber';
x:=1;
for c:='A' to 'Z' do begin
hDevice:=CreateFile(pansichar('\\.\'+c+':'), GENERIC_READ + GENERIC_WRITE, FILE_SHARE_READ + FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0);
status:=DeviceIoControl( hDevice, $002d1400, @query, sizeof(query), @devDesc, 512, cardinal(returnedLength), nil );
if status then
 begin
   stringgrid1.Cells[0,x]:=c;
//   if (devDesc.RemovableMedia) then memo1.Lines.Add('Removable Media');
   stringgrid1.Cells[1,x]:=getValue(devDesc,devDesc.VendorIdOffset);
   stringgrid1.Cells[2,x]:=getValue(devDesc,devDesc.ProductIdOffset);
   stringgrid1.Cells[3,x]:=getValue(devDesc,devDesc.ProductRevisionOffset);  
   case devDesc.BusType of
     BusTypeUnknown:s:='Unknown';
     BusTypeScsi:s:='SCSI';
     BusTypeAtapi:s:='ATAPI';
     BusTypeAta:s:='ATA';
     BusType1394:s:='IEEE 1394';
     BusTypeSsa:s:='SSA';
     BusTypeFibre:s:='FIBRE';
     BusTypeUsb:s:='USB';
     BusTypeRAID:s:='RAID';
    end;
   stringgrid1.Cells[4,x]:=s;
   ss:=getValue(devDesc,devDesc.SerialNumberOffset);
   s:='';
   for y:=1 to length(ss) div 2 do
    begin
    if not NUM(copy(ss,y*2-1,2)) then break;
    s:=s+chr(strtoint('$'+copy(ss,y*2-1,2)));
    end;
   stringgrid1.Cells[5,x]:=s;
   inc(x);
  end;
end;
end;

end.
Saludos..
Responder Con Cita