hiyohiyo / CrystalDiskInfo

CrystalDiskInfo
https://github.com/hiyohiyo/CrystalDiskInfo
MIT License
1.6k stars 178 forks source link

Use 'AtaSmart' library on another function #177

Closed camambeou closed 2 years ago

camambeou commented 2 years ago

I try to mod this project to separate services and UI ([issue 60])(https://github.com/hiyohiyo/CrystalDiskInfo/issues/60) I write a .cpp to use 'AtaSmart' library like this:

CAtaSmart m_Ata{}; m_Ata.Init(1, 1, 0, 1, 1, 1); ofstream myFile("C:\\ModelSerial.txt"); myFile << CT2A(m_Ata.vars[0].ModelSerial); myFile.close();

ModelSerials of SATA disks are got. But ModelSerials of NVMe disk is always null. Seem not found these disks. How can I fix that? Or where am I wrong?

camambeou commented 2 years ago

CArray<ATA_SMART_INFO, ATA_SMART_INFO> vars is always empty in this situation.

camambeou commented 2 years ago

I guess thì code cause that: if (IsWindowsVersionOrGreaterFx(10, 0)) { m_bAtaPassThrough = TRUE; m_bAtaPassThroughSmart = TRUE; m_bNVMeStorageQuery = TRUE; } else if (IsWindowsVersionOrGreaterFx(6, 0) || IsWindowsVersionOrGreaterFx(5, 2)) { m_bAtaPassThrough = TRUE; m_bAtaPassThroughSmart = TRUE; } else if (IsWindowsVersionOrGreaterFx(5, 1)) { if (IsWindowsVersionOrGreaterFx(5, 1, 2)) { m_bAtaPassThrough = TRUE; m_bAtaPassThroughSmart = TRUE; } } Run on Windows 10, the above code leads to else if (IsWindowsVersionOrGreaterFx(6, 0) || IsWindowsVersionOrGreaterFx(5, 2))

camambeou commented 2 years ago

I found my issue

zyyujq commented 1 year ago

How to solve the problem? How to modify the code?

zyyujq commented 1 year ago

It seems to be related to the operating system, WIN11 error, WIN7 can!

zyyujq commented 1 year ago

include

include

using namespace std;

CAtaSmart m_Ata{}; m_Ata.Init(1, 1, 0, 1, 1, 1); ofstream myFile("C:\ModelSerial.txt"); myFile << CT2A(m_Ata.vars[0].ModelSerial); myFile.close();

WIN7 , SATA SSD , passed!