lfreist / hwinfo

cross platform C++ library for hardware information (CPU, RAM, GPU, ...)
MIT License
438 stars 76 forks source link

fixbug: add wstring_to_std_tring, to fix disk._vendor decode bug, support getAvailableMemory on windows #27

Closed liguobao closed 1 year ago

liguobao commented 1 year ago

the code ”{tmp.begin(), tmp.end()}; “ decode fail on Windows.

it return " (屏豵╤)",

the right text is “ (标准磁盘驱动器)”.

--------------------------------- Disks ----------------------------------- Disk 0: vendor: (屏豵╤) model: Samsung SSD 980 1TB serial-number:
size: -1 Disk 1: vendor: (屏豵╤) model: WDC WD10EZEX-00BBHA0 serial-number:
size: -1

I had fix it.

----------------------------------- RAM ----------------------------------- vendor: A-DATA Technology model: name: 物理内存 serial-number: 7D950300 size [MiB]: 65277.4 free [MiB]: -9.53674e-07 ------------------------------- Main Board -------------------------------- vendor: ASUSTeK COMPUTER INC. name: PRIME Z690-P D4 version: Rev 1.xx serial-number: 7D950300 ------------------------------- Batteries --------------------------------- No Batteries installed or detected --------------------------------- Disks ----------------------------------- Disk 0: vendor: (标准磁盘驱动器) model: Samsung SSD 980 1TB serial-number:
size: -1 Disk 1: vendor: (标准磁盘驱动器) model: WDC WD10EZEX-00BBHA0 serial-number:
size: -1

lfreist commented 1 year ago

Hi, thank you for your contribution and fix. Please make sure, the code style gets fixed (c.f. GitHub action)

liguobao commented 1 year ago

Hi, thank you for your contribution and fix. Please make sure, the code style gets fixed (c.f. GitHub action)

OK, I fix it.

liguobao commented 1 year ago

I fix the disk size on windows, please merge it~

  std::vector<const wchar_t*> sizes;
  // it will return L"Size" Str
  wmi::queryWMI("Win32_DiskDrive", "Size", sizes);
  for (int i = 0; i < res.size(); ++i) {
    if (i >= disks.size()) {
      break;
    }
    disks[i]._size_Bytes = std::stoll(wstring_to_std_tring(sizes[i]));
  }

--------------------------------- Disks ----------------------------------- Disk 0: vendor: (标准磁盘驱动器) model: Samsung SSD 980 1TB serial-number:
size: 1000202273280 Disk 1: vendor: (标准磁盘驱动器) model: WDC WD10EZEX-00BBHA0 serial-number:
size: 1000202273280

lfreist commented 1 year ago

Hi! The result you posted looks good. However, the build fails for Linux (gcc and clang) and Windows (Visual Studio and MinGW). Also the code style requirements are not met yet.

liguobao commented 1 year ago

Hi! The result you posted looks good. However, the build fails for Linux (gcc and clang) and Windows (Visual Studio and MinGW). Also the code style requirements are not met yet.

OK, I had fix it~

liguobao commented 1 year ago

Please approval the workflows~ Thanks~~~

liguobao commented 1 year ago

I support getAvailableMemory on windows, please merge it.

https://github.com/lfreist/hwinfo/pull/27/commits/342ad7baa30489a81ae48ef037a7a813ef508ab4

liguobao commented 1 year ago

All Action is passed, please merge it~ Good night~