Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Прикладное программирование » Как получить ID компьютера?

Модерирует : ShIvADeSt

 Версия для печати • ПодписатьсяДобавить в закладки

Открыть новую тему     Написать ответ в эту тему

fabit



Newbie
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
Как в Делфях закодить получение ID Компьютера?

Всего записей: 9 | Зарегистр. 28-12-2005 | Отправлено: 06:45 01-03-2006
Cheery



.:МордератоР:.
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
fabit
а что ты называешь ID в данном случае?

----------
Away/DND

Всего записей: 52737 | Зарегистр. 04-04-2002 | Отправлено: 06:50 01-03-2006
fabit



Newbie
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
точно сам не знаю, но предполагаю что это каким-то образом полученный идентификационный номер всей конфигурации компьютера (наверно биос+мать+сетевуха и еще что-нибудь) А может я ошибаюсь, если что поправьте меня

Всего записей: 9 | Зарегистр. 28-12-2005 | Отправлено: 09:10 01-03-2006
diablist



Advanced Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
Нет такого, есть только ID компонентов т.е Винт, мать и.т.д

Всего записей: 898 | Зарегистр. 29-06-2002 | Отправлено: 07:04 03-03-2006
Xarde



Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
Может тебе нужен уникальный код установленной винды? (извините, забыл, как он обзывается). Если да, то порыскай по форуму - кажется, уже писали об этом.

Всего записей: 266 | Зарегистр. 06-07-2003 | Отправлено: 10:28 03-03-2006
emo

Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
Можно запаковать, например, в Armadillo программу и использовать функции SDK для получения HardwareID.

Всего записей: 373 | Зарегистр. 19-11-2003 | Отправлено: 20:27 16-04-2006
ReLock

Newbie
Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору
Попробуй это:
function GetMachineID: string;
 
var
  BiosID,
    BiosDate,
    BiosSerial,
    BiosInfo: string;
  UserCPU: string;
  GetMC: string;
 
  function IsOSNT: boolean;
  var
    OS: TOSVersionInfo;
  begin
    ZeroMemory(@OS, SizeOf(OS));
    OS.dwOSVersionInfoSize := SizeOf(OS);
    GetVersionEx(OS);
    result := OS.dwPlatformId = VER_PLATFORM_WIN32_NT;
  end;
 
  function DBGCheck: Boolean;
  begin
    try
      if IsOSNT = False then
      begin
        asm
     Mov Al,0ADh
     Out 64h,AL
     Mov Al,0AEh
     Out 64h,Al
        end;
      end;
    except
    end;
    if DebugHook = 0 then Result := False
    else
    begin
      Result := True;
    end;
  end;
 
// -------------------- Windows Product ID ---------------------//
 
  function GetProductID_w9x: string;
  var Reg: TRegistry;
  begin
    Reg := TRegistry.Create;
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    Reg.OpenKeyReadOnly('\Software\Microsoft\Windows\CurrentVersion');
    Result := Reg.ReadString('ProductId');
    Reg.Free;
  end;
 
  function GetProductID_wNT: string;
  var Reg: TRegistry;
  begin
    Reg := TRegistry.Create;
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    Reg.OpenKeyReadOnly('\Software\Microsoft\Windows\CurrentVersion');
    Result := Reg.ReadString('ProductID');
    Reg.Free;
  end;
 
  function GetDigitalID_wNT: string;
  const
    Key: string = '\Software\Microsoft\Windows NT\CurrentVersion';
    Val: string = 'DigitalProductID';
 
  var
    Data: array of Byte;
    S: string;
    sz: Word;
    I: Word;
    Reg: TRegistry;
 
  begin
    Reg := TRegistry.Create;
    with Reg do
    begin
      RootKey := HKEY_LOCAL_MACHINE;
      OpenKeyReadOnly(Key);
      if GetDataType(Val) = rdBinary
        then
      begin
        sz := GetDataSize(Val);
        if sz > 0 then
        begin
          SetLength(Data, sz);
          ReadBinaryData(Val, Data[0], sz);
          for I := 0 to sz - 1 do
          begin
            S := S + Format('%d', [Data[I]]);
          end;
          Result := S;
        end;
      end;
      Free;
    end;
  end;
 
 
 // -------------------- CPU Type Info --------------------- //
 
 
  function GetCPUIdentifier: string;
  var Reg: TRegistry;
  begin
    Reg := TRegistry.Create;
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    Reg.OpenKeyReadOnly('\Hardware\Description\System\CentralProcessor\0');
    Result := Reg.ReadString('Identifier');
    Reg.Free;
  end;
 
  function GetCPUVendor: string;
  var Reg: TRegistry;
  begin
    Reg := TRegistry.Create;
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    Reg.OpenKeyReadOnly('\Hardware\Description\System\CentralProcessor\0');
    Result := Reg.ReadString('VendorIdentifier');
    Reg.Free;
  end;
 
  function GetCPUName: string;
  var Reg: TRegistry;
  begin
    Reg := TRegistry.Create;
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    Reg.OpenKeyReadOnly('\Hardware\Description\System\CentralProcessor\0');
    Result := Reg.ReadString('ProcessorNameString');
    Reg.Free;
  end;
 
 function GetWindowsUserName: String;
  const
    MAX_LENGTH = 256;
  var
    UserNameLength: DWord;
  begin
    UserNameLength := MAX_LENGTH - 1;
    SetLength(Result, MAX_LENGTH);
    if GetUserName(PChar(Result), UserNameLength) then
      SetLength(Result, UserNameLength - 1)
    else
      Result := '';
  end;
 
{  function GetIdeDiskSerialNumber: 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;
    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
     // Get SCSI port handle
      hDevice := CreateFile('\\.\Scsi0:', GENERIC_READ or GENERIC_WRITE,
        FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0);
      if hDevice = INVALID_HANDLE_VALUE then Exit;
      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 := 0;
          with irDriveRegs do
          begin
            bFeaturesReg := 0;
            bSectorCountReg := 1;
            bSectorNumberReg := 1;
            bCylLowReg := 0;
            bCylHighReg := 0;
            bDriveHeadReg := $A0;
            bCommandReg := IDE_ID_FUNCTION;
          end;
        end;
        if not DeviceIoControl(hDevice, IOCTL_SCSI_MINIPORT, @Buffer, BufferSize, @Buffer, BufferSize, cbBytesReturned, nil) then Exit;
      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 Exit;
      try
        pInData := PSendCmdInParams(@Buffer);
        pOutData := PChar(@pInData^.bBuffer);
        with pInData^ do
        begin
          cBufferSize := IDENTIFY_BUFFER_SIZE;
          bDriveNumber := 0;
          with irDriveRegs do
          begin
            bFeaturesReg := 0;
            bSectorCountReg := 1;
            bSectorNumberReg := 1;
            bCylLowReg := 0;
            bCylHighReg := 0;
            bDriveHeadReg := $A0;
            bCommandReg := IDE_ID_FUNCTION;
          end;
        end;
        if not DeviceIoControl(hDevice, DFP_RECEIVE_DRIVE_DATA, pInData, SizeOf(TSendCmdInParams) - 1, pOutData, W9xBufferSize, cbBytesReturned, nil) then Exit;
      finally
        CloseHandle(hDevice);
      end;
    end;
    with PIdSector(PChar(pOutData) + 16)^ do
    begin
      ChangeByteOrder(sSerialNumber, SizeOf(sSerialNumber));
      SetString(Result, sSerialNumber, SizeOf(sSerialNumber));
    end;
  end;
 
  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;
 
  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
    dwReturned: 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;
 
  function GetHddSerial: string;
  var
    NumTry: Byte;
 
    FinalStr: string;
    hDevice: THandle;
    sDeviceName: string;
  begin
    NumTry := 1;
    repeat
      case NumTry of
        1:
          begin
            FinalStr := Trim(GetIdeDiskSerialNumber);
          end;
        2:
          begin
            sDeviceName := 'C:';
            hDevice := GetDeviceHandle(sDeviceName);
             
            if hDevice <> INVALID_HANDLE_VALUE then begin
              try
                FinalStr := Trim(ScsiHddSerialNumber(hDevice));
              finally
                CloseHandle(hDevice);
              end;
            end;
           end;
 
        3: begin
            FinalStr := 'Error!';
          end;
      end;
 
      Inc(NumTry);
    until (FinalStr <> '') or (NumTry > 3);
 
    Result := FinalStr;
  end;}
 
function GetIdeDiskSerialNumber: 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;
 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
     // Get SCSI port handle
     hDevice := CreateFile( '\\.\Scsi0:', GENERIC_READ or GENERIC_WRITE,
       FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0 );
     if hDevice=INVALID_HANDLE_VALUE then Exit;
     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 := 0;
         with irDriveRegs do
         begin
           bFeaturesReg     := 0;
           bSectorCountReg  := 1;
           bSectorNumberReg := 1;
           bCylLowReg       := 0;
           bCylHighReg      := 0;
           bDriveHeadReg    := $A0;
           bCommandReg      := IDE_ID_FUNCTION;
         end;
       end;
       if not DeviceIoControl( hDevice, IOCTL_SCSI_MINIPORT, @Buffer, BufferSize, @Buffer, BufferSize, cbBytesReturned, nil ) then Exit;
     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 Exit;
     try
       pInData := PSendCmdInParams(@Buffer);
       pOutData := PChar(@pInData^.bBuffer);
       with pInData^ do begin
         cBufferSize  := IDENTIFY_BUFFER_SIZE;
         bDriveNumber := 0;
         with irDriveRegs do begin
           bFeaturesReg     := 0;
           bSectorCountReg  := 1;
           bSectorNumberReg := 1;
           bCylLowReg       := 0;
           bCylHighReg      := 0;
           bDriveHeadReg    := $A0;
           bCommandReg      := IDE_ID_FUNCTION;
         end;
       end;
       if not DeviceIoControl( hDevice, DFP_RECEIVE_DRIVE_DATA, pInData, SizeOf(TSendCmdInParams)-1, pOutData, W9xBufferSize, cbBytesReturned, nil ) then Exit;
     finally
       CloseHandle(hDevice);
     end;
   end;
   with PIdSector(PChar(pOutData)+16)^ do begin
     ChangeByteOrder(sSerialNumber,SizeOf(sSerialNumber));
     SetString(Result,sSerialNumber,SizeOf(sSerialNumber));
     Result := Trim(Result);
   end;
end;
 
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: String;
{$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;
{ALIGN OFF}
var
  DeviceHandle : THandle;
  dwReturned : DWORD;
  len : DWORD;
  Buffer : Array[0..SizeOf(TScsiPassThroughWithBuffers)+SizeOf(TScsiPassThrough)-1] of Byte;
  sptwb : TScsiPassThroughWithBuffers absolute Buffer;
begin
  DeviceHandle := GetDeviceHandle('C:');
  If DeviceHandle <> INVALID_HANDLE_VALUE Then Begin
     Try
        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)^) );
        Result := Trim(Result);
     Finally
        CloseHandle(DeviceHandle);
     End;
  End;
end;
 
function GetLogicalSerial: String;
var
  D_Id, Tmp1, Tmp2: DWord;
begin
  GetVolumeInformation(PChar('c:\'), Nil, 0, @D_Id, Tmp1, Tmp2, Nil, 0);
  Result := Format('%8.8x', [D_Id]);
end;
 
function GetHddSerial: String;
var
  NumTry: Byte;
  FinalStr: String;
begin
  NumTry := 1;
  Repeat
     Case NumTry Of
        1: FinalStr := ScsiHddSerialNumber;
        2: FinalStr := GetIdeDiskSerialNumber;
        3: FinalStr := GetLogicalSerial;
        4: FinalStr := 'Error';
     End;
 
     Inc(NumTry);
  Until (FinalStr <> '') Or (NumTry > 4);
 
  Result := FinalStr;
end;
 
function CanGetHddSerial(Prepare: Boolean): Integer;
var
  WinPath: Array[0..44] Of Char;
  CopyFrom: String;
  CopyTo: String;
begin
  // Results:
  //    1 - Can get HDD Serial
  //    0 - Can get HDD Serial after reboot
  //   -1 - Can NOT get HDD Serial
 
  If Win32Platform = VER_PLATFORM_WIN32_NT Then
     Result := 1
        Else
     Begin
        If ScsiHddSerialNumber <> '' Then
           Result := 1
              Else
           Begin
              GetWindowsDirectory(WinPath, SizeOf(WinPath));
              CopyTo := WinPath + '\System\Iosubsys\Smartvsd.vxd';
              If FileExists(CopyTo) Then
                 Result := 1
                    Else
                 Begin
                    CopyFrom := WinPath + '\System\Smartvsd.vxd';
                    If Not FileExists(CopyFrom) Then
                       Result := -1
                          Else
                       Begin
                          If Prepare Then
                             Begin
                                If CopyFile(PChar(CopyFrom), PChar(CopyTo), False) Then
                                   Result := 0
                                      Else
                                   Result := -1;
                             End
                                Else
                             Result := -1;
                       End;
                 End;
           End;
     End;
end;
 
 
 
  function Hdd_Serial: string;
  var
    SerialNum: DWord;
    A, B: DWord;
    C: array[0..255] of Char;
    Buffer: array[0..255] of Char;
  begin
    if GetVolumeInformation(PChar('C:\'), Buffer, 256, @SerialNum, A, B, C, 256) then Result := IntToStr(SerialNum);
  end;
 
 
 
 
{--------------- XOR Encryption ---------------}
  function EnDecrypt(S: string): string;
  var
    x: Byte;
  begin
    RandSeed := 26153960;
    for x := 1 to Length(S) do S[x] := Chr(Ord(S[x]) xor (Random(128) or 128));
    EnDecrypt := S;
    Randomize;    
  end;
 
 
  function Get_UserMachineID: string;
  const
    rkBIOS = {HKEY_LOCAL_MACHINE\} 'HARDWARE\DESCRIPTION\System';
    rvBiosDate = 'SystemBiosDate';
    rvBiosID = 'Identifier';
    rvBiosVersion = 'SystemBiosVersion';
    DBRoot = HKEY_LOCAL_MACHINE;
 
  var
    BRegistry: TRegistry;
    IDPC: string;
 
  begin
    if (WindowsVersion = tWvWinnt4) or (WindowsVersion = tWvWin2k) or (WindowsVersion = tWvWinxp) then
    begin
      with TRegistry.Create do begin
        rootkey := HKEY_LOCAL_MACHINE;
        if OpenKeyReadOnly(rkBios) then begin
          if valueexists(rvBIOSID) then
            BiosID := readstring(rvBIOSID);
          if valueexists(rvBIOSDate) then
            BiosDate := readstring(rvBIOSDate);
          closekey;
        end;
        free;
      end;
    end
    else
    begin
      try
        BiosID := string(Pchar(Ptr($FE061)));
        BiosInfo := string(Pchar(Ptr($FE091)));
        BiosDate := string(Pchar(Ptr($FFFF5)));
        BiosSerial := string(Pchar(Ptr($FEC71)));
 
        if (BiosID = '') then
        begin
          BRegistry := TRegistry.Create;
          BRegistry.RootKey := DBRoot;
          BRegistry.LazyWrite := false;
          BRegistry.OpenKeyReadOnly('Enum\Root\*PNP0C01\0000');
          BiosDate := BRegistry.ReadString('BIOSDate');
          BiosID := BRegistry.ReadString('BIOSName');
          BiosInfo := BRegistry.ReadString('BIOSVersion');
          BRegistry.CloseKey;
          BRegistry.Free;
        end;
      except
        BiosID := 'Unsupported';
        BiosInfo := 'Unsupported';
        BiosSerial := 'Unsupported';
        BiosDate := 'Unsupported';
      end;
    end;
 
    if (WindowsVersion = tWvWinnt4) or (WindowsVersion = tWvWin2k) or (WindowsVersion = tWvWinxp) then
      IDPC := GetMD5(GetHddSerial + BiosID + ' ' + BiosDate + ' ' + BiosInfo + ' ' + BiosSerial)
 
    else IDPC := EnDecrypt(GetMD5(BiosID + ' ' + BiosDate + ' ' + BiosInfo + ' ' + BiosSerial));
 
    Get_UserMachineID := IDPC;
  end;
 
begin
  If CanGetHddSerial(True) = 0 Then
   Begin
    MessageDlg(#13+'You need to restart your computer.',MtInformation,[MbOK],0);
   End;
   
  If FAD Then If DBGCheck = False Then ADP;
  GetMC := GetCRC32(EnDecrypt(Get_UserMachineID));
  Insert('-', GetMC, 3);
  Insert('-', GetMC, 6);
  Insert('-', GetMC, 9);
 
  UserCPU := GetCRC32(GetMD5(EnDecrypt(Get_UserMachineID) + GetCPUName));
  Insert('-', UserCPU, 3);
  Insert('-', UserCPU, 6);
  Insert('-', UserCPU, 9);
  Result := UserCPU + '-' + GetMC;
end;
 
/* IceLicense 2.08*/

Всего записей: 11 | Зарегистр. 17-04-2006 | Отправлено: 12:59 17-04-2006 | Исправлено: ReLock, 13:00 17-04-2006
DroN_S

Advanced Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
ReLock
ты что решил вторую AIDA написать

Цитата:
точно сам не знаю, но предполагаю что это каким-то образом полученный идентификационный номер всей конфигурации компьютера (наверно биос+мать+сетевуха и еще что-нибудь) А может я ошибаюсь, если что поправьте меня

не понимаю, как можно писать то чего сам не знаешь что получится... так не бывает... не ставить цель и стремится на выходи получить нужный результат...

Всего записей: 1143 | Зарегистр. 09-04-2005 | Отправлено: 19:03 17-04-2006
ReLock

Newbie
Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору
DroN_S

Цитата:
ты что решил вторую AIDA написать

Нет конечно. Это код из IceLicense. Просто нашел и предложил.

Всего записей: 11 | Зарегистр. 17-04-2006 | Отправлено: 13:36 18-04-2006
Открыть новую тему     Написать ответ в эту тему

Компьютерный форум Ru.Board » Компьютеры » Прикладное программирование » Как получить ID компьютера?


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.Board
© Ru.B0ard 2000-2026

LiteCoin: LgY72v35StJhV2xbt8CpxbQ9gFY6jwZ67r

Рейтинг.ru

Рейтинг.ru