Determine GPU manufacturer on Windows - windows

I'm going to write a Windows application and it would be useful if the app could tell what graphics card is being used. At the least, it would be helpful to see the manufacturer of the GPU. I'm not set on a programming language as of yet.
What windows library exposes this information?

See here for a C# way of doing it, using WMI. You could access WMI through pretty much any language:
C# detect which graphics card drives video
ManagementObjectSearcher searcher
= new ManagementObjectSearcher("SELECT * FROM Win32_DisplayConfiguration");
string graphicsCard = string.Empty;
foreach (ManagementObject mo in searcher.Get())
{
foreach (PropertyData property in mo.Properties)
{
if (property.Name == "Description")
{
graphicsCard = property.Value.ToString();
}
}
}

Related

Where is the list of device driver images stored in ETW?

I am trying to programatically get the list of device drives from an ETW with the great TraceProcessing Library which is used by WPA.
using ITraceProcessor processor = TraceProcessor.Create(myEtlFile, new
TraceProcessorSettings
{
AllowLostEvents = true,
AllowTimeInversion = true,
});
myProcesses = processor.UseProcesses();
foreach (var process in myProcesses.Result.Processes)
{
foreach (var dll in process.Images)
{
// get dll.Path, dll.FileVersion, dll.ProductVersion, dll.ProductName, dll.FileVersionNumber, dll.FileDescription
}
}
This works for every process except the Kernel (System(4)). Why do I have only 3 dlls in the System process? I would expect the driver files in the System process there as well. In CPU sampling the image is there so it looks like everything is right there.
This would be very useful to check for driver versions if the data is present. But so far I was not able to find it. Am I missing something here?
Happy to hear you enjoy using the TraceProcessor library!
Device drivers are logged against the "Idle (0)" process by ETW, here is an example:
using var tp = TraceProcessor.Create(#"trace.etl");
var processes = tp.UseProcesses();
tp.Process();
var idleProcess = processes.Result.Processes.FirstOrDefault(x => x.Id == 0);
foreach (var image in idleProcess?.Images)
{
Console.WriteLine(image.Path);
}

Find permanently installed physical drives using WMI

I'm using WMI to find all the Win32_DiskDrives on a machine. I want to exclude drives temporarily installed, like USB drives.
Is there a way to do this?
You can search for USB devices using WMI like this:
public void CollectUSBDevices()
{
NameValueCollection collection = new NameValueCollection();
ManagementObjectSearcher searcher2 = new ManagementObjectSearcher("SELECT * FROM win32_pnpentity where deviceid like 'USB%'");
// Iterate through all found USB objects.
foreach (ManagementObject dm in searcher2.Get())
{
string nameValue = dm["Name"].ToString();
string devid = dm["DeviceID"].ToString();
if (nameValue.Contains("Generic USB Hub") || nameValue.Contains("USB Root Hub"))
continue;
if (nameValue.Contains("USB Mass Storage Device") || devid.Contains("USBSTOR\\"))
collection.Add("USBDevice", nameValue);
}
}

What api can I use to find the manufacturer of a system in Windows 8? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Windows VC++ Get Machine Model Name
I saw box.net detecting PC manufacturers and giving the users extra space in Windows 8. Which api can I use to find out the manufacturer?
You could use Windows Management Instrumentation
This example is in C#, hope it works for you.
string manufacturer = string.Empty;
ManagementClass mc = new System.Management.ManagementClass("Win32_BIOS");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if (string.IsNullOrEmpty(result))
{
try
{
if (mo["Manufacturer"] != null)
manufacturer = mo["Manufacturer"].ToString();
break;
}
// Show the exception (just for test purpose)
catch(Exception ex)
{
MessageBox.Show(ex.Message)
}
}
}
Console.WriteLine(manufacturer.Trim());

Windows Workflow Foundation 4.0 and Tracking

I'm working with the Beta 2 version of Visual Studio 2010 to get some advanced learning using WF4. I've been working with the SqlTracking Sample in the WF_WCF_Samples SDK, and have gotten a pretty good understanding of how to emit and store tracking data in a SQL Database, but haven't seen anything on how to query the data when needed. Does anyone know if there are any .Net classes that are to be used for querying the tracking data, and if so are there any known samples, tutorials, or articles that describe how to query the tracking data?
According to Matt Winkler, from the Microsoft WF4 Team, there isn't any built in API for querying the tracking data, the developer must write his/her own.
These can help:
WorkflowInstanceQuery Class
Workflow Tracking and Tracing
Tracking Participants in .NET 4 Beta 1
Old question, I know, but there is actually a more or less official API in AppFabric: Windows Server AppFabric Class Library
You'll have to find the actual DLL's in %SystemRoot%\AppFabric (after installing AppFabric, of course). Pretty weird place to put it.
The key classes to look are at are SqlInstanceQueryProvider, InstanceQueryExecuteArgs. The query API is asynchronous and can be used something like this (C#):
public InstanceInfo GetWorkflowInstanceInformation(Guid workflowInstanceId, string connectionString)
{
var instanceQueryProvider = new SqlInstanceQueryProvider();
// Connection string to the instance store needs to be set like this:
var parameters = new NameValueCollection()
{
{"connectionString", connectionString}
};
instanceQueryProvider.Initialize("Provider", parameters);
var queryArgs = new InstanceQueryExecuteArgs()
{
InstanceId = new List<Guid>() { workflowInstanceId }
};
// Total ruin the asynchronous advantages and use a Mutex to lock on.
var waitEvent = new ManualResetEvent(false);
IEnumerable<InstanceInfo> retrievedInstanceInfos = null;
var query = instanceQueryProvider.CreateInstanceQuery();
query.BeginExecuteQuery(
queryArgs,
TimeSpan.FromSeconds(10),
ar =>
{
lock (synchronizer)
{
retrievedInstanceInfos = query.EndExecuteQuery(ar).ToList();
}
waitEvent.Set();
},
null);
var waitResult = waitEvent.WaitOne(5000);
if (waitResult)
{
List<InstanceInfo> instances = null;
lock (synchronizer)
{
if (retrievedInstanceInfos != null)
{
instances = retrievedInstanceInfos.ToList();
}
}
if (instances != null)
{
if (instances.Count() == 1)
{
return instances.Single();
}
if (!instances.Any())
{
Log.Warning("Request for non-existing WorkflowInstanceInfo: {0}.", workflowInstanceId);
return null;
}
Log.Error("More than one(!) WorkflowInstanceInfo for id: {0}.", workflowInstanceId);
}
}
Log.Error("Time out retrieving information for id: {0}.", workflowInstanceId);
return null;
}
And just to clarify - this does NOT give you access to the tracking data, which are stored in the Monitoring Database. This API is only for the Persistence Database.

Retrieving graphics/sound card information on Windows

I'm working on a bug reporting tool for my application, and I'd like to attach hardware information to bug reports to make pinpointing certain problems easier. Does anyone know of any Win32 API functions to query the OS for information on the graphics and sound cards?
Thanks,
Rob
If your willing to dig into WMI the following should get you started.
using System;
using System.Management;
namespace WMIData
{
class Program
{
static void Main(string[] args)
{
SelectQuery querySound = new SelectQuery("Win32_SoundDevice");
ManagementObjectSearcher searcherSound = new ManagementObjectSearcher(querySound);
foreach (ManagementObject sound in searcherSound.Get())
{
Console.WriteLine("Sound device: {0}", sound["Name"]);
}
SelectQuery queryVideo = new SelectQuery("Win32_VideoController");
ManagementObjectSearcher searchVideo = new ManagementObjectSearcher(queryVideo);
foreach (ManagementObject video in searchVideo.Get())
{
Console.WriteLine("Video device: {0}", video["Name"]);
}
Console.ReadLine();
}
}
}
WMI .NET Overview
After posting noticed it wasn't marked .NET, however this could be of interest as well. Creating a WMI Application Using C++
I think your best bet is the DirectSound API, documented here:
http://msdn.microsoft.com/en-us/library/bb219833%28VS.85%29.aspx
Specifically, the DirectSoundEnumerate call.

Resources