Страница: 1 | 2 |
|
Вопрос: Заводской номер HDD в 64 bit компьютерах
|
Добавлено: 19.06.12 18:06
|
|
Автор вопроса: Эдик
|
Привет всем !
Как в 64 bit компах узнать заводской серийный номер HDD (Ноутбуков) .Старые способы пригодные для 32 bit компах здесь не пригодны.
Ответить
|
Номер ответа: 4 Автор ответа: Эдик
Вопросов: 19 Ответов: 23
|
Профиль | | #4
|
Добавлено: 20.06.12 05:53
|
Обычно ползуюсь этим
-
- Option Explicit
-
-
- Private Declare Function CreateFile Lib "kernel32.dll" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
- Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
- Private Declare Function DeviceIoControl Lib "kernel32.dll" (ByVal hDevice As Long, ByVal dwIoControlCode As Long, ByRef lpInBuffer As Any, ByVal nInBufferSize As Long, ByRef lpOutBuffer As Any, ByVal nOutBufferSize As Long, ByRef lpBytesReturned As Long, ByRef lpOverlapped As Long) As Long
- Private Declare Sub RtlZeroMemory Lib "kernel32.dll" (ByVal Destination As Long, ByVal Length As Long)
-
- Private Type GETVERSIONOUTPARAMS
-
- bVersion As Byte
- bRevision As Byte
- bReserved As Byte
- bIDEDeviceMap As Byte
- fCapabilities As Long
- dwReserved1 As Long
- dwReserved2 As Long
- dwReserved3 As Long
- dwReserved4 As Long
-
- End Type
-
- Private Type IDEREGS
-
- bFeaturesReg As Byte
- bSectorCountReg As Byte
- bSectorNumberReg As Byte
- bCylLowReg As Byte
- bCylHighReg As Byte
- bDriveHeadReg As Byte
- bCommandReg As Byte
- bReserved As Byte
-
- End Type
-
- Private Type SENDCMDINPARAMS
- cBufferSize As Long
- irDriveRegs As IDEREGS
- bDriveNumber As Byte
- bReserved(2) As Byte
- dwReserved(3) As Long
- bBuffer As Byte
- End Type
-
- Private Type DRIVERSTATUS
- bDriverError As Byte
- bIDEStatus As Byte
- bReserved(1) As Byte
- dwReserved(1) As Long
- End Type
-
- Private Type SENDCMDOUTPARAMS
- cBufferSize As Long
- DRIVERSTATUS As DRIVERSTATUS
- bBuffer As String * 512
- End Type
-
- Private Const INVALID_HANDLE_VALUE As Long = &HFFFFFFFF
- Private Const GENERIC_READ As Long = &H80000000
- Private Const GENERIC_WRITE As Long = &H40000000
- Private Const FILE_SHARE_READ As Long = &H1
- Private Const FILE_SHARE_WRITE As Long = &H2
- Private Const OPEN_EXISTING As Long = 3
-
- Private Const DFP_GET_VERSION As Long = &H74080
- Private Const DFP_RECEIVE_DRIVE_DATA As Long = &H7C088
-
- Private Const IDE_ATAPI_IDENTIFY As Long = &HA1
- Private Const IDE_ATA_IDENTIFY As Long = &HEC
-
- Private Const IDENTIFY_BUFFER_SIZE As Long = 512&
- Private Const SIZE_IDOUTCMD As Long = &H11 + IDENTIFY_BUFFER_SIZE - 1&
-
-
- Private Sub Form_Load()
-
- Dim VersParams As GETVERSIONOUTPARAMS, _
- scip As SENDCMDINPARAMS, _
- IdOutCmd As SENDCMDOUTPARAMS, _
- cbRead As Long, _
- bIDCmd As Byte
-
- Dim i As Long, _
- l As Long
- Dim hDrive As Long
-
- Do
- Call RtlZeroMemory(VarPtr(IdOutCmd), Len(IdOutCmd))
-
- hDrive = CreateFile("\\.\PhysicalDrive" & CStr(i), GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, 0&, OPEN_EXISTING, 0&, 0&)
- If hDrive = INVALID_HANDLE_VALUE Then _
- Exit Do
-
- Call RtlZeroMemory(VarPtr(VersParams), Len(VersParams))
- If Not (DeviceIoControl(hDrive, DFP_GET_VERSION, ByVal 0&, 0&, VersParams, Len(VersParams), cbRead, ByVal 0&) = 0&) Then
-
- If (VersParams.bIDEDeviceMap > 0) Then
-
- bIDCmd = VersParams.bIDEDeviceMap
- bIDCmd = bIDCmd \ 2 ^ i
- bIDCmd = bIDCmd And &H10
-
- If Not (bIDCmd = 0&) Then _
- bIDCmd = &HFFFFFFFF
-
- bIDCmd = bIDCmd And &HB5
- bIDCmd = bIDCmd And IDE_ATA_IDENTIFY
- bIDCmd = bIDCmd + IDE_ATA_IDENTIFY
-
- Call RtlZeroMemory(VarPtr(scip), Len(scip))
-
- scip.cBufferSize = IDENTIFY_BUFFER_SIZE
- scip.irDriveRegs.bFeaturesReg = 0&
- scip.irDriveRegs.bSectorCountReg = 1&
- scip.irDriveRegs.bSectorNumberReg = 1&
- scip.irDriveRegs.bCylLowReg = 0&
- scip.irDriveRegs.bCylHighReg = 0&
- scip.irDriveRegs.bCommandReg = bIDCmd
- scip.irDriveRegs.bDriveHeadReg = ((bIDCmd And 1&) * 2& ^ &O4) Or &HA0
- scip.bDriveNumber = i
-
- If Not (DeviceIoControl(hDrive, DFP_RECEIVE_DRIVE_DATA, scip, Len(scip) - 1&, IdOutCmd, Len(IdOutCmd), cbRead, ByVal 0&) = 0&) Then
-
- For l = 21 To 41& Step 2&
- Mid(IdOutCmd.bBuffer, l, 2) = Mid$(IdOutCmd.bBuffer, l + 1&, 1&) & Mid$(IdOutCmd.bBuffer, l, 1&)
- Next
-
- For l = 55 To 95 Step 2&
- Mid(IdOutCmd.bBuffer, l, 2) = Mid$(IdOutCmd.bBuffer, l + 1&, 1&) & Mid$(IdOutCmd.bBuffer, l, 1&)
- Next
-
- Me.FontName = "Courier New"
- Me.FontSize = 10&
- Me.Print "Number: " & i + 1& & vbCrLf & _
- "Device: " & Trim$(Mid$(IdOutCmd.bBuffer, 55, 40)) & vbCrLf & _
- "Serial: " & Trim$(Mid$(IdOutCmd.bBuffer, 21, 20)) & vbCrLf
-
- End If
-
- End If
-
- End If
-
- Call CloseHandle(hDrive)
- i = i + 1&
-
- Loop
-
- Me.FontName = "MS Sans Serif"
- Me.FontSize = 8&
-
- Me.Print String$(Me.ScaleWidth \ Me.TextWidth("-") + 1, "-") & vbCrLf & vbCrLf & _
- "(c) Team HomeWork (sne) 2006" & vbCrLf & _
- "mailto: sne_pro@mail.ru" & vbCrLf & vbCrLf & _
- "full source by SolidX:" & vbCrLf & _
- "http://www.wasm.ru/srclist.php?list=6"
-
- Me.Height = Me.CurrentY + (Me.Height - Me.ScaleHeight)
-
- End Sub
-
Ответить
|
Страница: 1 | 2 |
Поиск по форуму