Windows: Ensure returned value type is checked #84
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm opening this PR because I got a report from a user that was not able to get the RAM SerialNumber, and others having various sporadic issue also around RAM across other fields. This made me wonder how the code is shielding and making sure that only when the value is a valid one is being used.
Checking just the result of the
hr
unfortunately is not enough as the call my succeed but the value of the string but be NULL, so an additional check is required as per documentation.So by following that I added those checks in all windows entries where we query information via the WMI layer.
While doing so, and running the example project I noticed that the Capacity for the Battery was always returning
-nan
for Windows, which to my own surprise I found out the values are hardcoded. Not focusing on fixing this part, atm I just made sure the calculation returns 0, instead of-nan
.Finally also while running the test and checking information I found out that the Disk size was reported incorrectly as the
Size
field is a string, not an integer, for some reason so I'm parsing and converting that to a valid integer. Now the disk size in bytes is reported correctly.