GARANTIR DESCONTO

Fórum Pegar Nº Serial da Placa Mãe #269368

20/02/2005

0

Olá Pessoal,

Tenho uma aplicação que bloqueia as cópia através do serial do HDD, mas sempre que o usuário formata a máquina ou muda de HDD eu tenho que dar um novo código, pois o serial do HDD muda, gostaria de saber como fazer para pegar o Serial da Placa Mãe, pois é um hardware que dificilmente é trocado.

Obrigado.


Leandrosl2

Leandrosl2

Responder

Posts

20/02/2005

Ilopaiz

Acho q a melhor maneira é memorizar o tipo de processador, memória, sistema operacional, junto com o HD... aí vc vai ter um bloqueio eficiente... mas sempre q algo mudar vc vai ter q dar uma nova serial... a única maneira de evitar q copiem é vc guardar todos esses dados... se vc guardar só o número do HD, alguém pode levar esse HD para outra máquina e usar seu sistema sem permissão...

OK?


Responder

Gostei + 0

21/02/2005

Titanius

Pois eh... estou com este mesmo ´problema´.

Porem, como pegar todos esses dados?

[]s


Responder

Gostei + 0

21/02/2005

Leandrosl2

Eu só preciso saber como pegar o serial da placa mãe, pois isso seria o ideal para minha aplicação.


Responder

Gostei + 0

21/02/2005

Onjahyr

É facil.

Vá no site dos fabricantes das placas e localize o link oferecido para os desenvolvedores de softwares, mas vou logo adiantando que o código está em C (c++ não, é C puro mesmo hehehehe)

Falow


Responder

Gostei + 0

21/02/2005

Universodosoftware

Colega, o serial que você está pegando no hd onde está armazenado o sistema não é seguro, pois é como vc falou quando o usuário formata a máquina é dado um novo serial ao volume montado pelo S.O., mas ninguém ainda comentou aqui neste tópico que existe o serial de fabrica do hd, que é possível vc pegá-lo através da sua aplicação delphi e utilizá-lo como deseja.

No caso seria mais vantajoso vc adquirir o serial de fábrica do hd ao invés da placa mãe, creio eu que vc teria menos problemas futuros.

Caso não encontre o componente poste que envio alguns componentes que pegam o serial de fábrica do hd.


Responder

Gostei + 0

21/02/2005

Gandalf.nho

Para o serial de fábrica do HD olhe aqui: [url]http://home.earthlink.net/~akonshin/delphi_components.htm[/url]


Responder

Gostei + 0

21/02/2005

Dbergkamps

Colega, o serial que você está pegando no hd onde está armazenado o sistema não é seguro, pois é como vc falou quando o usuário formata a máquina é dado um novo serial ao volume montado pelo S.O., mas ninguém ainda comentou aqui neste tópico que existe o serial de fabrica do hd, que é possível vc pegá-lo através da sua aplicação delphi e utilizá-lo como deseja.

Estou com este mesmo problema. E vou utilizar o Serial do HD, que apesar de depois de formatado mudar certo, mas quando formata a aplicação também vai pro beleléu e ai de qualquer jeito eu vou ter que instalar de novo a aplicação.
Valeu. 8)


Responder

Gostei + 0

21/02/2005

Leandrosl2

Colega, o serial que você está pegando no hd onde está armazenado o sistema não é seguro, pois é como vc falou quando o usuário formata a máquina é dado um novo serial ao volume montado pelo S.O., mas ninguém ainda comentou aqui neste tópico que existe o serial de fabrica do hd, que é possível vc pegá-lo através da sua aplicação delphi e utilizá-lo como deseja. No caso seria mais vantajoso vc adquirir o serial de fábrica do hd ao invés da placa mãe, creio eu que vc teria menos problemas futuros. Caso não encontre o componente poste que envio alguns componentes que pegam o serial de fábrica do hd.


Se vc puder me mandar o componentes que pega esse serial de fábrica eu agradeço.


Responder

Gostei + 0

22/02/2005

Titanius

Amigos, pesquisando junto ao ClubeDelphi, descobri um topico do amigo Vinicius2K, que trata exatamente sobre o serial de fábrica do HD.

Amigo bergkamps, o serial de fábrica do HD não muda... mesmo formatando, removendo a partição, fazer ghost.. não muda, isso é como o chassi do carro, tem como mudar? com certeza.. porem a pessoa deverá ter um conhecimento altíssimo de Assembler para isto, que acredito eu, nem 0,5¬ dos nosso clientes sabem disso... :D

Então é isso, a melhor maneira que encontrei eh usar o serial fisico do HD, pois o da Placa Mãe, não encontrei nada parecido em DElphi... :(

Segue o Codigo:

// Extracting IDE(ATA) disk serial number.

// (c) 2000-2003 Alex Konshin
//               mailto:akonshin@earthlink.net
//               http://home.earthlink.net/~akonshin/index.htm
//
// 30 Jul 2000 created
// 22 Oct 2003 refactoring

unit HDFunc;

interface 

//------------------------------------------------------------- 
// Tries to extract the serial number from the first IDE disk that is found in the system. 
// Returns an empty string if IDE disk is not found. 
  function GetIdeSN : String; 

//------------------------------------------------------------- 
// Tries to extract the serial number from specified IDE disk. 
// 
// Parameters: 
//   ControllerNumber - SCSI port number of the controller. 
//   DriveNumber - Device index (0..4). 
// 
// Raises OSError exception in case of any error during this operation. 
// 
// Notes: 
//  1. The parameter ControllerNumber is ignored on Windows 9x/ME platforms and should be 0. 
//  2. This function CAN NOT extract SCSI disk serial number. 
// 
  function GetIdeDiskSerialNumber( ControllerNumber, DriveNumber : Integer ) : String; 

//============================================================= 
implementation 

uses 
  Windows, 
  SysUtils; // only for Win32Platform, SysErrorMessage and class Exception 

{$IFDEF VER150} 
{$DEFINE VER140} 
{$ENDIF} 

{$IFNDEF VER140} 
procedure RaiseLastOSError; 
begin 
  RaiseLastWin32Error; 
end; 
{$ENDIF} 

//------------------------------------------------------------- 
// Tries to extract the serial number from specified IDE disk. 
// 
// Parameters: 
//   ControllerNumber - SCSI port number of the controller. 
//   DriveNumber - SCSI port number of the controller. 
// Notes: 
//  1. The parameter ControllerNumber is ignored on Windows 9x/ME platforms and should be 0. 
//  2. This function CAN NOT extract SCSI disk serial number. 
// 
function GetIdeDiskSerialNumber( ControllerNumber, DriveNumber : Integer ) : String; 
type 
  TSrbIoControl = packed record 
    HeaderLength : ULONG; 
    Signature    : Array[0..7] of Char; 
    Timeout      : ULONG; 
    ControlCode  : ULONG; 
    ReturnCode   : ULONG; 
    Length       : ULONG; 
  end; 
  SRB_IO_CONTROL = TSrbIoControl; 
  PSrbIoControl = ^TSrbIoControl; 

  TIDERegs = packed record 
    bFeaturesReg     : Byte; // Used for specifying SMART "commands". 
    bSectorCountReg  : Byte; // IDE sector count register 
    bSectorNumberReg : Byte; // IDE sector number register 
    bCylLowReg       : Byte; // IDE low order cylinder value 
    bCylHighReg      : Byte; // IDE high order cylinder value 
    bDriveHeadReg    : Byte; // IDE drive/head register 
    bCommandReg      : Byte; // Actual IDE command. 
    bReserved        : Byte; // reserved for future use.  Must be zero. 
  end; 
  IDEREGS   = TIDERegs; 
  PIDERegs  = ^TIDERegs; 

  TSendCmdInParams = packed record 
    cBufferSize  : DWORD;                // Buffer size in bytes 
    irDriveRegs  : TIDERegs;             // Structure with drive register values. 
    bDriveNumber : Byte;                 // Physical drive number to send command to (0,1,2,3). 
    bReserved    : Array[0..2] of Byte;  // Reserved for future expansion. 
    dwReserved   : Array[0..3] of DWORD; // For future use. 
    bBuffer      : Array[0..0] of Byte;  // Input buffer. 
  end; 
  SENDCMDINPARAMS   = TSendCmdInParams; 
  PSendCmdInParams  = ^TSendCmdInParams; 

  TIdSector = packed record 
    wGenConfig                 : Word; 
    wNumCyls                   : Word; 
    wReserved                  : Word; 
    wNumHeads                  : Word; 
    wBytesPerTrack             : Word; 
    wBytesPerSector            : Word; 
    wSectorsPerTrack           : Word; 
    wVendorUnique              : Array[0..2] of Word; 
    sSerialNumber              : Array[0..19] of Char; 
    wBufferType                : Word; 
    wBufferSize                : Word; 
    wECCSize                   : Word; 
    sFirmwareRev               : Array[0..7] of Char; 
    sModelNumber               : Array[0..39] of Char; 
    wMoreVendorUnique          : Word; 
    wDoubleWordIO              : Word; 
    wCapabilities              : Word; 
    wReserved1                 : Word; 
    wPIOTiming                 : Word; 
    wDMATiming                 : Word; 
    wBS                        : Word; 
    wNumCurrentCyls            : Word; 
    wNumCurrentHeads           : Word; 
    wNumCurrentSectorsPerTrack : Word; 
    ulCurrentSectorCapacity    : ULONG; 
    wMultSectorStuff           : Word; 
    ulTotalAddressableSectors  : ULONG; 
    wSingleWordDMA             : Word; 
    wMultiWordDMA              : Word; 
    bReserved                  : Array[0..127] of Byte; 
  end; 
  PIdSector = ^TIdSector; 

const 
  IDE_ID_FUNCTION = $EC; 
  IDENTIFY_BUFFER_SIZE       = 512; 
  DFP_RECEIVE_DRIVE_DATA        = $0007c088; 
  IOCTL_SCSI_MINIPORT           = $0004d008; 
  IOCTL_SCSI_MINIPORT_IDENTIFY  = $001b0501; 
  DataSize = sizeof(TSendCmdInParams)-1+IDENTIFY_BUFFER_SIZE; 
  BufferSize = SizeOf(SRB_IO_CONTROL)+DataSize; 
  W9xBufferSize = IDENTIFY_BUFFER_SIZE+16; 
var 
  hDevice : THandle; 
  cbBytesReturned : DWORD; 
  s : String; 
  pInData : PSendCmdInParams; 
  pOutData : Pointer; // PSendCmdInParams; 
  Buffer : Array[0..BufferSize-1] of Byte; 
  srbControl : TSrbIoControl absolute Buffer; 

  procedure ChangeByteOrder( var Data; Size : Integer ); 
  var ptr : PChar; 
      i : Integer; 
      c : Char; 
  begin 
    ptr := @Data; 
    for i := 0 to (Size shr 1)-1 do 
    begin 
      c := ptr^; 
      ptr^ := (ptr+1)^; 
      (ptr+1)^ := c; 
      Inc(ptr,2); 
    end; 
  end; 

begin 
  Result := ´´; 
  FillChar(Buffer,BufferSize,#0); 
  if Win32Platform=VER_PLATFORM_WIN32_NT then 
    begin // Windows NT, Windows 2000 
      Str(ControllerNumber,s); 
      // Get SCSI port handle 
      hDevice := CreateFile( 
        PChar(´\\.\Scsi´+s+´:´), 
        GENERIC_READ or GENERIC_WRITE, 
        FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0 ); 
      if hDevice=INVALID_HANDLE_VALUE then RaiseLastOSError; 
      try 
        srbControl.HeaderLength := SizeOf(SRB_IO_CONTROL); 
        System.Move(´SCSIDISK´,srbControl.Signature,8); 
        srbControl.Timeout      := 2; 
        srbControl.Length       := DataSize; 
        srbControl.ControlCode  := IOCTL_SCSI_MINIPORT_IDENTIFY; 
        pInData := PSendCmdInParams(PChar(@Buffer)+SizeOf(SRB_IO_CONTROL)); 
        pOutData := pInData; 
        with pInData^ do 
        begin 
          cBufferSize  := IDENTIFY_BUFFER_SIZE; 
          bDriveNumber := DriveNumber; 
          with irDriveRegs do 
          begin 
            bFeaturesReg     := 0; 
            bSectorCountReg  := 1; 
            bSectorNumberReg := 1; 
            bCylLowReg       := 0; 
            bCylHighReg      := 0; 
            bDriveHeadReg    := $A0 or ((DriveNumber and 1) shl 4); 
            bCommandReg      := IDE_ID_FUNCTION; 
          end; 
        end; 
        if not DeviceIoControl( hDevice, IOCTL_SCSI_MINIPORT, @Buffer, BufferSize, @Buffer, BufferSize, cbBytesReturned, nil ) then RaiseLastOSError; 
      finally 
        CloseHandle(hDevice); 
      end; 
    end 
  else 
    begin // Windows 95 OSR2, Windows 98 
      hDevice := CreateFile( ´\\.\SMARTVSD´, 0, 0, nil, CREATE_NEW, 0, 0 ); 
      if hDevice=INVALID_HANDLE_VALUE then RaiseLastOSError; 
      try 
        pInData := PSendCmdInParams(@Buffer); 
        pOutData := PChar(@pInData^.bBuffer); 
        with pInData^ do 
        begin 
          cBufferSize  := IDENTIFY_BUFFER_SIZE; 
          bDriveNumber := DriveNumber; 
          with irDriveRegs do 
          begin 
            bFeaturesReg     := 0; 
            bSectorCountReg  := 1; 
            bSectorNumberReg := 1; 
            bCylLowReg       := 0; 
            bCylHighReg      := 0; 
            bDriveHeadReg    := $A0 or ((DriveNumber and 1) shl 4); 
            bCommandReg      := IDE_ID_FUNCTION; 
          end; 
        end; 
        if not DeviceIoControl( hDevice, DFP_RECEIVE_DRIVE_DATA, pInData, SizeOf(TSendCmdInParams)-1, pOutData, W9xBufferSize, cbBytesReturned, nil ) then RaiseLastOSError; 
      finally 
        CloseHandle(hDevice); 
      end; 
    end; 

  with PIdSector(PChar(pOutData)+16)^ do 
  begin 
    ChangeByteOrder(sSerialNumber,SizeOf(sSerialNumber)); 
    SetString(Result,sSerialNumber,SizeOf(sSerialNumber)); 
  end; 

  Result := Trim(Result); 

end; 

//------------------------------------------------------------- 
function GetIdeSN : String; 
var 
  iController, iDrive, maxController : Integer; 
begin 
  Result := ´´; 
  maxController := 15; 
  if Win32Platform<>VER_PLATFORM_WIN32_NT then maxController := 0; 
  for iController := 0 to maxController do 
  begin 
    for iDrive := 0 to 4 do 
    begin 
      try 
        Result := GetIdeDiskSerialNumber(iController,iDrive); 
        if Result<>´´ then Exit; 
      except 
        // ignore exceptions 
      end; 
    end; 
  end; 
end; 

end.


Para usar faça assim:

var
 s: string;
begin
 s := GetIdeSN;
if s <> ´´ then ShowMessage(s);
end;


Então é isso, espero ter ajudado a galera..

[]s


Responder

Gostei + 0

25/02/2005

Christian_adriano

Olá pessoal eu tenho duas Units para pegar seriais dos HDs (IDE, Scsi):

unit ScsiSN;

interface

uses
Windows, SysUtils;

{$ALIGN ON}
type
TScsiPassThrough = record
Length : Word;
ScsiStatus : Byte;
PathId : Byte;
TargetId : Byte;
Lun : Byte;
CdbLength : Byte;
SenseInfoLength : Byte;
DataIn : Byte;
DataTransferLength : ULONG;
TimeOutValue : ULONG;
DataBufferOffset : DWORD;
SenseInfoOffset : ULONG;
Cdb : Array[0..15] of Byte;
end;
TScsiPassThroughWithBuffers = record
spt : TScsiPassThrough;
bSenseBuf : Array[0..31] of Byte;
bDataBuf : Array[0..191] of Byte;
end;

var
hDevice : THandle = 0;
sSerNum, sDeviceName, Resultado : String;

implementation

//-------------------------------------------------------------
function GetDeviceHandle( sDeviceName : String ) : THandle;
begin
Result := CreateFile( PChar(´\\.\´+sDeviceName), GENERIC_READ or GENERIC_WRITE,
FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0 )
end;

//-------------------------------------------------------------
function ScsiHddSerialNumber( DeviceHandle : THandle ) : String;
{ALIGN OFF}
vardwReturned : DWORD;
len : DWORD;
Buffer : Array[0..SizeOf(TScsiPassThroughWithBuffers)+SizeOf(TScsiPassThrough)-1] of Byte;
sptwb : TScsiPassThroughWithBuffers absolute Buffer;
begin
Result := ´´;
FillChar(Buffer,SizeOf(Buffer),#0);
with sptwb.spt do
begin
Length := SizeOf(TScsiPassThrough);
CdbLength := 6; // CDB6GENERIC_LENGTH
SenseInfoLength := 24;
DataIn := 1; // SCSI_IOCTL_DATA_IN
DataTransferLength := 192;
TimeOutValue := 2;
DataBufferOffset := PChar(@sptwb.bDataBuf)-PChar(@sptwb);
SenseInfoOffset := PChar(@sptwb.bSenseBuf)-PChar(@sptwb);
Cdb[0] := $12; //OperationCode := SCSIOP_INQUIRY;
Cdb[1] := $01; //Flags := CDB_INQUIRY_EVPD; Vital product data
Cdb[2] := $80; //PageCode Unit serial number
Cdb[4] := 192; // AllocationLength
end;
len := sptwb.spt.DataBufferOffset+sptwb.spt.DataTransferLength;
if DeviceIoControl( DeviceHandle, $0004d004, @sptwb, SizeOf(TScsiPassThrough), @sptwb, len, dwReturned, nil )
and ((PChar(@sptwb.bDataBuf)+1)^=#$80)
then SetString( Result, PChar(@sptwb.bDataBuf)+4, Ord((PChar(@sptwb.bDataBuf)+3)^) );
end;

procedure RetornarSerial;
begin
sDeviceName := ParamStr(1);
if Trim(sDeviceName) = ´´ then
begin
Resultado := ´´;
Exit;
end;
hDevice := GetDeviceHandle(sDeviceName);
if hDevice=INVALID_HANDLE_VALUE then
Resultado := ´´ //(´Error on GetDeviceHandle: ´ + SysErrorMessage(GetLastError))
else
try
sSerNum := ScsiHddSerialNumber(hDevice);
if Trim(sSerNum) = ´´ then
Resultado := ´´ //(´Error on DeviceIoControl: ´ + SysErrorMessage(GetLastError))
else
Resultado := Trim(sSerNum);
finally
CloseHandle(hDevice);
end;
end;

end.


-----------------------------------------------------------------------------------

unit IdeSN;

interface

//-------------------------------------------------------------
// Tries to extract the serial number from the first IDE disk that is found in the system.
// Returns an empty string if IDE disk is not found.
function GetIdeSN : String;

//-------------------------------------------------------------
// Tries to extract the serial number from specified IDE disk.
//
// Parameters:
// ControllerNumber - SCSI port number of the controller.
// DriveNumber - Device index (0..4).
//
// Raises OSError exception in case of any error during this operation.
//
// Notes:
// 1. The parameter ControllerNumber is ignored on Windows 9x/ME platforms and should be 0.
// 2. This function CAN NOT extract SCSI disk serial number.
//
function GetIdeDiskSerialNumber( ControllerNumber, DriveNumber : Integer ) : String;

//=============================================================
implementation

uses
Windows,
SysUtils; // only for Win32Platform, SysErrorMessage and class Exception

{$IFDEF VER150}
{$DEFINE VER140}
{$ENDIF}

{$IFNDEF VER140}
procedure RaiseLastOSError;
begin
RaiseLastWin32Error;
end;
{$ENDIF}

//-------------------------------------------------------------
// Tries to extract the serial number from specified IDE disk.
//
// Parameters:
// ControllerNumber - SCSI port number of the controller.
// DriveNumber - SCSI port number of the controller.
// Notes:
// 1. The parameter ControllerNumber is ignored on Windows 9x/ME platforms and should be 0.
// 2. This function CAN NOT extract SCSI disk serial number.
//
function GetIdeDiskSerialNumber( ControllerNumber, DriveNumber : Integer ) : String;
type
TSrbIoControl = packed record
HeaderLength : ULONG;
Signature : Array[0..7] of Char;
Timeout : ULONG;
ControlCode : ULONG;
ReturnCode : ULONG;
Length : ULONG;
end;
SRB_IO_CONTROL = TSrbIoControl;
PSrbIoControl = ^TSrbIoControl;

TIDERegs = packed record
bFeaturesReg : Byte; // Used for specifying SMART ´commands´.
bSectorCountReg : Byte; // IDE sector count register
bSectorNumberReg : Byte; // IDE sector number register
bCylLowReg : Byte; // IDE low order cylinder value
bCylHighReg : Byte; // IDE high order cylinder value
bDriveHeadReg : Byte; // IDE drive/head register
bCommandReg : Byte; // Actual IDE command.
bReserved : Byte; // reserved for future use. Must be zero.
end;
IDEREGS = TIDERegs;
PIDERegs = ^TIDERegs;

TSendCmdInParams = packed record
cBufferSize : DWORD; // Buffer size in bytes
irDriveRegs : TIDERegs; // Structure with drive register values.
bDriveNumber : Byte; // Physical drive number to send command to (0,1,2,3).
bReserved : Array[0..2] of Byte; // Reserved for future expansion.
dwReserved : Array[0..3] of DWORD; // For future use.
bBuffer : Array[0..0] of Byte; // Input buffer.
end;
SENDCMDINPARAMS = TSendCmdInParams;
PSendCmdInParams = ^TSendCmdInParams;

TIdSector = packed record
wGenConfig : Word;
wNumCyls : Word;
wReserved : Word;
wNumHeads : Word;
wBytesPerTrack : Word;
wBytesPerSector : Word;
wSectorsPerTrack : Word;
wVendorUnique : Array[0..2] of Word;
sSerialNumber : Array[0..19] of Char;
wBufferType : Word;
wBufferSize : Word;
wECCSize : Word;
sFirmwareRev : Array[0..7] of Char;
sModelNumber : Array[0..39] of Char;
wMoreVendorUnique : Word;
wDoubleWordIO : Word;
wCapabilities : Word;
wReserved1 : Word;
wPIOTiming : Word;
wDMATiming : Word;
wBS : Word;
wNumCurrentCyls : Word;
wNumCurrentHeads : Word;
wNumCurrentSectorsPerTrack : Word;
ulCurrentSectorCapacity : ULONG;
wMultSectorStuff : Word;
ulTotalAddressableSectors : ULONG;
wSingleWordDMA : Word;
wMultiWordDMA : Word;
bReserved : Array[0..127] of Byte;
end;
PIdSector = ^TIdSector;

const
IDE_ID_FUNCTION = $EC;
IDENTIFY_BUFFER_SIZE = 512;
DFP_RECEIVE_DRIVE_DATA = $0007c088;
IOCTL_SCSI_MINIPORT = $0004d008;
IOCTL_SCSI_MINIPORT_IDENTIFY = $001b0501;
DataSize = sizeof(TSendCmdInParams)-1+IDENTIFY_BUFFER_SIZE;
BufferSize = SizeOf(SRB_IO_CONTROL)+DataSize;
W9xBufferSize = IDENTIFY_BUFFER_SIZE+16;
var
hDevice : THandle;
cbBytesReturned : DWORD;
s : String;
pInData : PSendCmdInParams;
pOutData : Pointer; // PSendCmdInParams;
Buffer : Array[0..BufferSize-1] of Byte;
srbControl : TSrbIoControl absolute Buffer;

procedure ChangeByteOrder( var Data; Size : Integer );
var ptr : PChar;
i : Integer;
c : Char;
begin
ptr := @Data;
for i := 0 to (Size shr 1)-1 do
begin
c := ptr^;
ptr^ := (ptr+1)^;
(ptr+1)^ := c;
Inc(ptr,2);
end;
end;

begin
Result := ´´;
FillChar(Buffer,BufferSize,#0);
if Win32Platform=VER_PLATFORM_WIN32_NT then
begin // Windows NT, Windows 2000
Str(ControllerNumber,s);
// Get SCSI port handle
hDevice := CreateFile(
PChar(´\\.\Scsi´+s+´:´),
GENERIC_READ or GENERIC_WRITE,
FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0 );
if hDevice=INVALID_HANDLE_VALUE then RaiseLastOSError;
try
srbControl.HeaderLength := SizeOf(SRB_IO_CONTROL);
System.Move(´SCSIDISK´,srbControl.Signature,8);
srbControl.Timeout := 2;
srbControl.Length := DataSize;
srbControl.ControlCode := IOCTL_SCSI_MINIPORT_IDENTIFY;
pInData := PSendCmdInParams(PChar(@Buffer)+SizeOf(SRB_IO_CONTROL));
pOutData := pInData;
with pInData^ do
begin
cBufferSize := IDENTIFY_BUFFER_SIZE;
bDriveNumber := DriveNumber;
with irDriveRegs do
begin
bFeaturesReg := 0;
bSectorCountReg := 1;
bSectorNumberReg := 1;
bCylLowReg := 0;
bCylHighReg := 0;
bDriveHeadReg := $A0 or ((DriveNumber and 1) shl 4);
bCommandReg := IDE_ID_FUNCTION;
end;
end;
if not DeviceIoControl( hDevice, IOCTL_SCSI_MINIPORT, @Buffer, BufferSize, @Buffer, BufferSize, cbBytesReturned, nil ) then RaiseLastOSError;
finally
CloseHandle(hDevice);
end;
end
else
begin // Windows 95 OSR2, Windows 98
hDevice := CreateFile( ´\\.\SMARTVSD´, 0, 0, nil, CREATE_NEW, 0, 0 );
if hDevice=INVALID_HANDLE_VALUE then RaiseLastOSError;
try
pInData := PSendCmdInParams(@Buffer);
pOutData := PChar(@pInData^.bBuffer);
with pInData^ do
begin
cBufferSize := IDENTIFY_BUFFER_SIZE;
bDriveNumber := DriveNumber;
with irDriveRegs do
begin
bFeaturesReg := 0;
bSectorCountReg := 1;
bSectorNumberReg := 1;
bCylLowReg := 0;
bCylHighReg := 0;
bDriveHeadReg := $A0 or ((DriveNumber and 1) shl 4);
bCommandReg := IDE_ID_FUNCTION;
end;
end;
if not DeviceIoControl( hDevice, DFP_RECEIVE_DRIVE_DATA, pInData, SizeOf(TSendCmdInParams)-1, pOutData, W9xBufferSize, cbBytesReturned, nil ) then RaiseLastOSError;
finally
CloseHandle(hDevice);
end;
end;

with PIdSector(PChar(pOutData)+16)^ do
begin
ChangeByteOrder(sSerialNumber,SizeOf(sSerialNumber));
SetString(Result,sSerialNumber,SizeOf(sSerialNumber));
end;

Result := Trim(Result);

end;

//-------------------------------------------------------------
function GetIdeSN : String;
var
iController, iDrive, maxController : Integer;
begin
Result := ´´;
maxController := 15;
if Win32Platform<>VER_PLATFORM_WIN32_NT then maxController := 0;
for iController := 0 to maxController do
begin
for iDrive := 0 to 4 do
begin
try
Result := GetIdeDiskSerialNumber(iController,iDrive);
if Result<>´´ then Exit;
except
// ignore exceptions
end;
end;
end;
end;

end.


-----------------------------------------------------------------------------------

Forma de Usar:

function PegarSerialIDE : String;
begin
Result := Trim(GetIdeSN);
end;


function PegarSerialSCSI : String;
begin
Result := Trim(Resultado);
end;


Abraços,
Christian.


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar