You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 24, 2022. It is now read-only.
The way that you're going about pulling Hardware, Software and other System Information right now is causing you to have a lot of unnecessary code. I can also tell, by the comments you've written, that you don't know what a lot of the offsets mean.
There's a pretty easy way to handle pulling information about the Operating System, RAM, CPU, HDDs, etc.
First off, here's some code I wrote to easily run a PowerShell command from C# and have the output redirected to you ─
Next, here's an example of a command I wrote to pull the Manufacturer, Part Number, Capacity and Speed of all installed RAM sticks. It then converts them to JSON which you can very easily parse in C# ─
publicclassRAM{publicstringManufacturer{get;set;}publicstringPartNumber{get;set;}publicintCapacity{get;set;}publicintSpeed{get;set;}// THIS WILL NOT WORK UNLESS YOU UPGRADE FROM .NET FRAMEWORK 4.8 TO .NET 5.0publicstatic RAM GetInfo(){string_cim="Get-CimInstance -ClassName CIM_Chip |Select-Object Manufacturer,PartNumber,Capacity,Speed -ExcludeProperty 'CIM*' |ConvertTo-Json";stringjson= PowerShell.ExecuteCommand(_cim);return JsonSerializer.Deserialize<RAM[]>(json);}
The usage would be something like this ─
publicvoidform1_loaded(){int_totalRAM;var_RAM= RAM.GetInfo();foreach(var _stick in _RAM){_totalRAM=_totalRAM+ _stick.Capacity;}var_KB=_totalRAM/1024;var_MB=_KB/1024;var_GB=_MB/1024;
MessageBox.Show("You have "+ _GB.ToString()+"GB RAM installed!","Information");}
I hope this helps! Let me know if you need any further assistance with it. I've attached a list of all the CIM classes you can use (there are a lot...) It's a CSV file but GitHub wouldn't let me attach it with that extension, so just rename it to .csv and you'll be good to go. CimClasses-CSV.txt
The way that you're going about pulling Hardware, Software and other System Information right now is causing you to have a lot of unnecessary code. I can also tell, by the comments you've written, that you don't know what a lot of the offsets mean.
There's a pretty easy way to handle pulling information about the Operating System, RAM, CPU, HDDs, etc.
First off, here's some code I wrote to easily run a PowerShell command from C# and have the output redirected to you ─
Next, here's an example of a command I wrote to pull the Manufacturer, Part Number, Capacity and Speed of all installed RAM sticks. It then converts them to JSON which you can very easily parse in C# ─
Here's an example of the output ─
Here's an example C# class that you could use ─
The usage would be something like this ─
I hope this helps! Let me know if you need any further assistance with it. I've attached a list of all the CIM classes you can use (there are a lot...) It's a CSV file but GitHub wouldn't let me attach it with that extension, so just rename it to .csv and you'll be good to go.
CimClasses-CSV.txt
EDIT: Link to some CimInstance documentation by Microsoft: https://docs.microsoft.com/en-us/powershell/module/cimcmdlets/get-ciminstance?view=powershell-7.1#examples
The text was updated successfully, but these errors were encountered: