Dynamic library for accessing S.M.A.R.T. information, based on CrystalDiskInfo.
- Windows XP and later
- x64, x86 and Arm64 architectures
Warning
The host application that loads and calls this DLL must be run with administrator privileges.
Gets the CDI version.
- Parameters: None.
- Return Value: The CDI version string, e.g.,
"9.0.0".
Creates a SMART data structure.
- Note:
CoInitializeExmust be called before this function after loading the DLL.- You should call this function first to create a
CDI_SMARTstructure before using other functions exceptcdi_get_version. - Call
cdi_destroy_smartto free the memory when done.
- Parameters: None.
- Return Value: A pointer to a
CDI_SMARTstructure for use with other functions. - Reference:
Frees the SMART data structure.
- Parameters:
ptr: A pointer to theCDI_SMARTstructure obtained fromcdi_create_smart.
- Return Value: None.
Initializes the SMART data.
- Note:
- This function should be called after
cdi_create_smartto initialize the SMART data. - It scans all disks and collects S.M.A.R.T. information, which may take some time.
- This function should be called after
- Parameters:
ptr: A pointer to theCDI_SMARTstructure.flags: Various options for disk processing. See the Disk Processing Options section below. The recommended value is0x01FBFF81.
- Return Value: None.
Updates the S.M.A.R.T. information for a specific disk.
- Parameters:
ptr: A pointer to theCDI_SMARTstructure.index: The disk index, starting from 0. The maximum value iscdi_get_disk_count() - 1.
- Return Value: The DWORD value indicating the update status.
0if the disk's S.M.A.R.T. information has not changed.- Non-zero if the S.M.A.R.T. information has changed.
Gets the number of detected disks.
- Parameters:
ptr: A pointer to theCDI_SMARTstructure.
- Return Value: The total count of disks.
Gets a boolean disk attribute.
- Parameters:
ptr: A pointer to theCDI_SMARTstructure.index: The disk index.attr: The attribute to retrieve. See the Disk Attributes (BOOL) section.
- Return Value: The boolean value of the specified attribute.
Gets an integer disk attribute.
- Parameters:
ptr: A pointer to theCDI_SMARTstructure.index: The disk index.attr: The attribute to retrieve. See the Disk Attributes (INT) section.
- Return Value: The integer value of the specified attribute.
- A negative value indicates that the attribute is not available.
Gets a DWORD disk attribute.
- Parameters:
ptr: A pointer to theCDI_SMARTstructure.index: The disk index.attr: The attribute to retrieve. See the Disk Attributes (DWORD) section.
- Return Value: The DWORD value of the specified attribute.
Gets a string disk attribute.
- Parameters:
ptr: A pointer to theCDI_SMARTstructure.index: The disk index.attr: The attribute to retrieve. See the Disk Attributes (WCHAR)* section.
- Return Value: The string value of the specified attribute. Use
cdi_free_stringto release the memory.
Frees the memory allocated for a string.
- Parameters:
ptr: The string pointer to be freed.
- Return Value: None.
Gets the S.M.A.R.T. data format string.
- Parameters:
ptr: A pointer to theCDI_SMARTstructure.index: The disk index.
- Return Value: A string representing the S.M.A.R.T. data format. Use
cdi_free_stringto release the memory.- Possible values are
RawValues(7),RawValues(8),Cur RawValues(8),Cur Wor --- RawValues(6),Cur Wor Thr RawValues(6),Cur Wor --- RawValues(7)andCur Wor Thr RawValues(7).
- Possible values are
Gets the ID of a specific S.M.A.R.T. attribute.
- Parameters:
ptr: A pointer to theCDI_SMARTstructure.index: The disk index.attr: The S.M.A.R.T. attribute index, from0toCDI_DWORD_ATTR_COUNT - 1.
- Return Value: The ID of the S.M.A.R.T. attribute.
Gets the formatted value of a specific S.M.A.R.T. attribute.
- Parameters:
ptr: A pointer to theCDI_SMARTstructure.index: The disk index.attr: The S.M.A.R.T. attribute index, from0toCDI_DWORD_ATTR_COUNT - 1.hex: IfTRUE, the raw value will be formatted as hexadecimal.
- Return Value: A string representing the S.M.A.R.T. attribute data. Use
cdi_free_stringto release the memory.
Gets the status of a specific S.M.A.R.T. attribute.
- Parameters:
ptr: A pointer to theCDI_SMARTstructure.index: The disk index.attr: The S.M.A.R.T. attribute index, from0toCDI_DWORD_ATTR_COUNT - 1.
- Return Value: The status of the S.M.A.R.T. attribute. See the Disk Health Status section.
Gets the name of a S.M.A.R.T. attribute by its ID.
- Parameters:
ptr: A pointer to theCDI_SMARTstructure.index: The disk index.id: The ID of the S.M.A.R.T. attribute, obtained fromcdi_get_smart_id.
- Return Value: The name of the S.M.A.R.T. attribute. Use
cdi_free_stringto release the memory.
#define CDI_FLAG_USE_WMI (1ULL << 0) // TRUE
#define CDI_FLAG_ADVANCED_SEARCH (1ULL << 1) // FALSE
#define CDI_FLAG_WORKAROUND_HD204UI (1ULL << 2) // FALSE
#define CDI_FLAG_WORKAROUND_ADATA (1ULL << 3) // FALSE
#define CDI_FLAG_HIDE_NO_SMART (1ULL << 4) // FALSE
#define CDI_FLAG_SORT_DRIVE_LETTER (1ULL << 5) // FALSE
#define CDI_FLAG_NO_WAKEUP (1ULL << 6) // FALSE
#define CDI_FLAG_ATA_PASS_THROUGH (1ULL << 7) // TRUE
#define CDI_FLAG_ENABLE_NVIDIA (1ULL << 8) // TRUE
#define CDI_FLAG_ENABLE_MARVELL (1ULL << 9) // TRUE
#define CDI_FLAG_ENABLE_USB_SAT (1ULL << 10) // TRUE
#define CDI_FLAG_ENABLE_USB_SUNPLUS (1ULL << 11) // TRUE
#define CDI_FLAG_ENABLE_USB_IODATA (1ULL << 12) // TRUE
#define CDI_FLAG_ENABLE_USB_LOGITEC (1ULL << 13) // TRUE
#define CDI_FLAG_ENABLE_USB_PROLIFIC (1ULL << 14) // TRUE
#define CDI_FLAG_ENABLE_USB_JMICRON (1ULL << 15) // TRUE
#define CDI_FLAG_ENABLE_USB_CYPRESS (1ULL << 16) // TRUE
#define CDI_FLAG_ENABLE_USB_MEMORY (1ULL << 17) // TRUE
#define CDI_FLAG_ENABLE_NVME_JMICRON (1ULL << 19) // TRUE
#define CDI_FLAG_ENABLE_NVME_ASMEDIA (1ULL << 20) // TRUE
#define CDI_FLAG_ENABLE_NVME_REALTEK (1ULL << 21) // TRUE
#define CDI_FLAG_ENABLE_MEGA_RAID (1ULL << 22) // TRUE
#define CDI_FLAG_ENABLE_INTEL_VROC (1ULL << 23) // TRUE
#define CDI_FLAG_ENABLE_ASM1352R (1ULL << 24) // TRUE
#define CDI_FLAG_ENABLE_AMD_RC2 (1ULL << 25) // FALSE
#define CDI_FLAG_ENABLE_REALTEK_9220DP (1ULL << 26) // FALSE
#define CDI_FLAG_HIDE_RAID_VOLUME (1ULL << 27) // TRUEenum CDI_ATA_BOOL
CDI_BOOL_SSD: Is Solid State DriveCDI_BOOL_SSD_NVME: Is NVMe SSD (Win10+)CDI_BOOL_SMART: S.M.A.R.T. supportedCDI_BOOL_LBA48: LBA48 supportedCDI_BOOL_AAM: AAM supportedCDI_BOOL_APM: APM supportedCDI_BOOL_NCQ: NCQ supportedCDI_BOOL_NV_CACHE: NV Cache supportedCDI_BOOL_DEVSLP: DEVSLP supportedCDI_BOOL_STREAMING: Streaming supportedCDI_BOOL_GPL: GPL supportedCDI_BOOL_TRIM: TRIM supportedCDI_BOOL_VOLATILE_WRITE_CACHE: Volatile Write Cache supportedCDI_BOOL_SMART_ENABLED: S.M.A.R.T. is enabledCDI_BOOL_AAM_ENABLED: AAM is enabledCDI_BOOL_APM_ENABLED: APM is enabled
enum CDI_ATA_INT
CDI_INT_DISK_ID: Disk ID (e.g., of\\.\PhysicalDriveX)CDI_INT_DISK_STATUS: Health status (See Disk Health Status)CDI_INT_SCSI_PORT: SCSI PortCDI_INT_SCSI_TARGET_ID: SCSI Target IDCDI_INT_SCSI_BUS: SCSI BusCDI_INT_POWER_ON_HOURS: Power on hoursCDI_INT_TEMPERATURE: Temperature (°C)CDI_INT_TEMPERATURE_ALARM: Temperature alarm threshold (°C)CDI_INT_HOST_WRITES: Total host writes (GB)CDI_INT_HOST_READS: Total host reads (GB)CDI_INT_NAND_WRITES: Total NAND writes (GB)CDI_INT_GB_ERASED: Gigabytes erased (GB)CDI_INT_WEAR_LEVELING_COUNT: Wear Leveling CountCDI_INT_LIFE: Health percentage (0% - 100%)CDI_INT_MAX_ATTRIBUTE: Max attribute count
enum CDI_ATA_DWORD
CDI_DWORD_DISK_SIZE: Disk size (MB)CDI_DWORD_LOGICAL_SECTOR_SIZE: Logical sector sizeCDI_DWORD_PHYSICAL_SECTOR_SIZE: Physical sector sizeCDI_DWORD_BUFFER_SIZE: Buffer size (Bytes)CDI_DWORD_ATTR_COUNT: Total number of S.M.A.R.T. attributesCDI_DWORD_POWER_ON_COUNT: Power on countCDI_DWORD_ROTATION_RATE: Rotation rate (RPM)CDI_DWORD_DRIVE_LETTER: Drive letter mapCDI_DWORD_DISK_VENDOR_ID: Disk vendor ID
enum CDI_ATA_STRING
CDI_STRING_SN: Serial NumberCDI_STRING_FIRMWARE: Firmware VersionCDI_STRING_MODEL: Model NameCDI_STRING_DRIVE_MAP: Drive letter list (e.g., "C: D:")CDI_STRING_TRANSFER_MODE_MAX: Maximum transfer modeCDI_STRING_TRANSFER_MODE_CUR: Current transfer modeCDI_STRING_INTERFACE: Interface type (e.g., "NVM Express")CDI_STRING_VERSION_MAJOR: Major versionCDI_STRING_VERSION_MINOR: Minor versionCDI_STRING_PNP_ID: Plug and Play IDCDI_STRING_SMART_KEY: S.M.A.R.T. KeyCDI_STRING_FORM_FACTOR: Form factor (inch)
enum CDI_DISK_STATUS
CDI_DISK_STATUS_UNKNOWN: UnknownCDI_DISK_STATUS_GOOD: GoodCDI_DISK_STATUS_CAUTION: CautionCDI_DISK_STATUS_BAD: Bad