MatthewKing / DeviceId

A simple library providing functionality to generate a 'device ID' that can be used to uniquely identify a computer.
MIT License
722 stars 118 forks source link

Possible incorrect Windows version returned #83

Closed jwilo closed 7 months ago

jwilo commented 7 months ago

Morning, we're using DeviceID 6.6.0, and have noticed a discrepancy between Windows OS version as reported by Windows, and that reported by DeviceID.

Construction of device id for log file using DeviceID follows:

string deviceId = new DeviceIdBuilder()
                                        .AddMachineName()
                                        .AddOsVersion()
                                        .OnWindows(windows => windows.AddWindowsDeviceId())
                                        .OnWindows(windows => windows.AddWindowsProductId())
                                        .UseFormatter(new StringDeviceIdFormatter(new PlainTextDeviceIdComponentEncoder(), ","))
                                        .ToString();

On development machine this returns OS version of Microsoft Windows NT 10.0.19045.0 which presumably is Windows 10.0, build 19045.0.

Running winver in CMD however returns build 19045.3693.

I fully appreciate I might be being dense, maybe just misunderstanding MS build numbers, or is there something amiss? Many thanks!

MatthewKing commented 7 months ago

Good morning.

That method just wraps Environment.OSVersion. My understanding is that this doesn't return the revision number of the OS version, just major.minor.build. Looking at https://github.com/dotnet/runtime/issues/76823, it seems that this is intentional by Microsoft ("The OS does not provide an API for querying the revision, so without that there is nothing more we can do here").

So, you're not misunderstanding anything - it's just that the Environment.OSVersion API only returns major.minor.build and not major.minor.build.revision.

Cheers!

jwilo commented 7 months ago

Hi Matthew, understood, thanks. Appreciate your quick feedback on this one. That closes this out nicely for us, closing this ticket. All the best.