C
C#15mo ago
yz

❔ Problem with getting GPU info

I'm currently working on a console program that shows some information of user's PC for fun. I have a problem with getting GPU info, when user is using laptop. In my case, I have RTX on my laptop but the program only shows Intel UHD. How to get REAL GPU information? Not only the name of RTX, I am gonna need more information like temperatures, or etc. This is a part of my code.
internal class GPUInfo
{
public string Name { get; private set; }
public string DriverVersion { get; private set; }
public GPUInfo()
{
Name = string.Empty;
DriverVersion = string.Empty;
}
public void Update()
{
using (var searcher = new ManagementObjectSearcher("select * from Win32_VideoController"))
{
foreach (var obj in searcher.Get())
{
Name = obj["Name"] != null ? obj["Name"].ToString() : "Unknown";
DriverVersion = obj["DriverVersion"] != null ? obj["DriverVersion"].ToString() : "Unknown";
}
}
}
}
internal class GPUInfo
{
public string Name { get; private set; }
public string DriverVersion { get; private set; }
public GPUInfo()
{
Name = string.Empty;
DriverVersion = string.Empty;
}
public void Update()
{
using (var searcher = new ManagementObjectSearcher("select * from Win32_VideoController"))
{
foreach (var obj in searcher.Get())
{
Name = obj["Name"] != null ? obj["Name"].ToString() : "Unknown";
DriverVersion = obj["DriverVersion"] != null ? obj["DriverVersion"].ToString() : "Unknown";
}
}
}
}
5 Replies
XANDRO
XANDRO15mo ago
Can you try this :
No description
XANDRO
XANDRO15mo ago
What does count says? Is there 1 or more?
yz
yzOP15mo ago
Count is 2! I tried CopyTo() and fixed it. Never thought of checking Count...Thanks!
XANDRO
XANDRO15mo ago
Yea that is the reason, your laptop have 2 gpu's one is integrated which is probably first object and other one is rtx.
Accord
Accord15mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server