If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

WMI in C# .NET Giving Different Results to WMI in Native C DLL

Hey,

I'm using WMI in C# .NET to retrieve some hardware information, including the current Win32_VideoController "Name". In C# on Windows 8 for a lot (or possibly all) people it seems to obtain information about a completely different video controller to that of when my native C DLL requests the same information.

For example, in Windows 8 the name seems to say "Microsoft Basic Render Driver" with C# and "NVIDIA GeForce 550 TI" via my native DLL. Why would this happen?

I know in the native code I'm explicitly connecting to the "ROOT\CIMV2" scope, but I did try doing that in C# and it made no difference.

Why would these 2 bits of code get information about 2 completely different video controllers on the same computer? And they even run in the same process. The C# code runs inside a C# .NET exe, and the native DLL is loaded by the C# .NET exe and called via an export in the DLL.

Re: WMI in C# .NET Giving Different Results to WMI in Native C DLL

Originally Posted by Arjay

Your code doesn't handle the case where more than one controller is returned.

Yeah I did realise that, but:

1) Why would the native DLL get a different first returned controller to the C#? Are the lists reversed or something?
2) How could I make sure the same controller is returned in both sets of code? I don't want to do something unstable like comparing the "Name" string to "Microsoft Basic Render Driver", not to mention that it wouldn't necessarily come up with that if it grabs an alternate video controller on a non-Windows 8 machine.

Is there an entry in the Win32_VideoController that specifies if it's the primary device? I had a look through the entries but I can't see what I might be able to check.