WindowsVersion.fromOSVERSIONINFOEXW constructor

WindowsVersion.fromOSVERSIONINFOEXW(
  1. OSVERSIONINFOEXW info
)

Constructs a WindowsVersion from OSVERSIONINFOEXW.

Implementation

factory WindowsVersion.fromOSVERSIONINFOEXW(OSVERSIONINFOEXW info) {
  final csdVersionCharCodes = <int>[];
  for (var i = 0; i < 128; i++) {
    final charCode = info.szCSDVersion[i];
    if (charCode == 0x00) {
      break;
    }
    csdVersionCharCodes.add(charCode);
  }
  final csdVersion = String.fromCharCodes(csdVersionCharCodes);
  return WindowsVersion(
    majorVersion: info.dwMajorVersion,
    minorVersion: info.dwMinorVersion,
    buildNumber: info.dwBuildNumber,
    csdVersion: csdVersion,
    servicePackMajor: info.wServicePackMajor,
    servicePackMinor: info.wServicePackMinor,
    type: info.wProductType.toWindowsType(),
  );
}