Zippo() wrote:
But my laptop is another matter. It is running Vista Home Premium on a SCSI hard drive.
Could you try the following code? Your HDD is SCSI, but obviously not RAID, so the code might work.
Code:
idxDrv := 0 ; 1, 2, etc
If Not 1 + hDrive:=DllCall("CreateFile", "str", "\\.\PhysicalDrive" . idxDrv, "Uint", 0, "Uint", 3, "Uint", 0, "Uint", 3, "Uint", 0, "Uint", 0)
ExitApp
VarSetCapacity(qr,12,0), VarSetCapacity(dd,8,0)
; IOCTL_STORAGE_QUERY_PROPERTY
If DllCall("DeviceIoControl", "Uint", hDrive, "Uint", 0x002D1400, "Uint", &qr, "Uint", VarSetCapacity(qr), "Uint", &dd, "Uint", VarSetCapacity(dd), "UintP", nReturn, "Uint", 0)
&& VarSetCapacity(dd,NumGet(dd,4))
&& DllCall("DeviceIoControl", "Uint", hDrive, "Uint", 0x002D1400, "Uint", &qr, "Uint", VarSetCapacity(qr), "Uint", &dd, "Uint", VarSetCapacity(dd), "UintP", nReturn, "Uint", 0)
MsgBox, % ((nOff:=NumGet(dd,24,"int"))<>-1 ? "Serial Number:`t""" . DecodeSN(DllCall("msvcrt\abs", "int", &dd+nOff, "Cdecl Str")) . """`n" : "")
. ((nOff:=NumGet(dd,16)) ? "Model Number:`t""" . DllCall("msvcrt\abs", "int", &dd+nOff, "Cdecl Str") . """`n" : "")
. ((nOff:=NumGet(dd,20)) ? "Revision Number:`t""" . DllCall("msvcrt\abs", "int", &dd+nOff, "Cdecl Str") . """`n" : "")
DllCall("CloseHandle", "Uint", hDrive)
Return
DecodeSN(h)
{
Loop, % StrLen(h)//4
SN .= Chr("0x" . SubStr(h,4*A_Index-1,2)) . Chr("0x" . SubStr(h,4*A_Index-3,2))
Return SN
}