http://diskinfo.nakatome.org/diskinfo.rar
or http://diskinfo.nakatome.org/diskinfo.zip
Don't forget to read readme.txt!
Here is an example (also provided in the archive) of how to use this library
Code: Select all
Structure DISK_INFO
ModelNumber.b[64]
SerialNumber.b[64]
ControllerVersion.b[64]
ControllerID.b
BufferSize.l
Type.b
Sectors.l
DiskSize1.l ; *COUGH* could use 64 bit integer support here !!
DiskSize2.l
EndStructure
If OpenLibrary(0,"diskinfo.dll") = 0
Debug "LIBRARY OPEN FAILED"
EndIf
; First you have to know how many hard disks are attached
; to the system. This will always be between 1 and 4.
DiskCount = CallFunction(0,"GetDiskCount")
Debug "Detected "+ Str(DiskCount) +" hard disk(s)"
Debug ""
; You can retrieve the data all at once by declaring the appropriate
; structure, and calling the GetDiskInfo() function. You can then
; get each piece of data out of the structure manually.
DiskInfo.DISK_INFO
ModelNumber.s = Space(64)
SerialNumber.s = Space(64)
ControllerVersion.s = Space(64)
For DiskID = 1 To DiskCount
Debug "Disk - "+ Str(DiskID)
Result = CallFunction(0,"GetDiskInfo",DiskID,@DiskInfo);
CopyMemory(@DiskInfo\ModelNumber, @ModelNumber, 64)
CopyMemory(@DiskInfo\SerialNumber, @SerialNumber, 64)
CopyMemory(@DiskInfo\ControllerVersion,@ControllerVersion,64)
Debug " Model Number: "+ ModelNumber
Debug " Serial Number: "+ SerialNumber
Debug " Controller Version: "+ ControllerVersion
Select DiskInfo\ControllerID
Case 1: Debug " This disk is on the Primary IDE Controller (Master)"
Case 2: Debug " This disk is on the Secondary IDE Controller (Slave)"
Case 3: Debug " This disk is on the Tertiary IDE Controller (Master)"
Case 4: Debug " This disk is on the Quaternary IDE Controller (Slave)"
EndSelect
Select DiskInfo\Type
Case 0: Debug " Type: Unknown"
Case 1: Debug " Type: Fixed"
Case 2: Debug " Type: Removable"
EndSelect
Debug " Buffer Size: "+ Str(DiskInfo\BufferSize) +" bytes"
Debug " Disk Size: "+ StrF(DiskInfo\Sectors * 512,0) +" bytes" ; This little hack will work For drives up To 2TB large.
;Debug " Disk Size: "+ Str(DiskInfo\DiskSize) +" bytes" ; Hopefully by the time those are here, PB will have 64-bit
; integer support, so we don't have to do that hack!
Debug ""
Next
; Or, you can get each piece of data one at a time. Useful
; if you only want to know certain things about the disk
DiskSize.l
DiskSerial.s = Space(64)
If CallFunction(0,"GetDiskSectors",1,@DiskSize)
Debug "Disk 1 size: "+ StrF(DiskSize * 512,0) +" bytes"
EndIf
; If you only have 1 hard disk, this will show nothing
If CallFunction(0,"GetDiskSerial",2,@DiskSerial)
Debug "Disk 2 serial: "+ DiskSerial
EndIf
CloseLibrary(0)
End
Enjoy !
(Don't worry Rings, this isn't the code you gave me. I was finally able to get that C++ code transformed into a DLL properly :)