Try and find a sensible video driver to report on rather than assuming it's video0.

This commit is contained in:
Jeremy Booth 2010-03-12 20:15:38 +00:00
parent c3d6d43d2a
commit cb925a91e9
1 changed files with 29 additions and 11 deletions

View File

@ -341,17 +341,32 @@ final class WindowsDisplay implements DisplayImplementation {
public String getAdapter() { public String getAdapter() {
try { try {
String adapter_string = WindowsRegistry.queryRegistrationKey( String maxObjNo = WindowsRegistry.queryRegistrationKey(
WindowsRegistry.HKEY_LOCAL_MACHINE, WindowsRegistry.HKEY_LOCAL_MACHINE,
"HARDWARE\\DeviceMap\\Video", "HARDWARE\\DeviceMap\\Video",
"\\Device\\Video0"); "MaxObjectNumber");
String root_key = "\\registry\\machine\\"; int maxObjectNumber = maxObjNo.charAt(0);
if (adapter_string.toLowerCase().startsWith(root_key)) { String vga_driver_value = "";
String driver_value = WindowsRegistry.queryRegistrationKey( for(int i=0;i<maxObjectNumber;i++) {
String adapter_string = WindowsRegistry.queryRegistrationKey(
WindowsRegistry.HKEY_LOCAL_MACHINE, WindowsRegistry.HKEY_LOCAL_MACHINE,
adapter_string.substring(root_key.length()), "HARDWARE\\DeviceMap\\Video",
"InstalledDisplayDrivers"); "\\Device\\Video" + i);
return driver_value; String root_key = "\\registry\\machine\\";
if (adapter_string.toLowerCase().startsWith(root_key)) {
String driver_value = WindowsRegistry.queryRegistrationKey(
WindowsRegistry.HKEY_LOCAL_MACHINE,
adapter_string.substring(root_key.length()),
"InstalledDisplayDrivers");
if(driver_value.toUpperCase().startsWith("VGA")) {
vga_driver_value = driver_value;
} else if(!driver_value.toUpperCase().startsWith("RDP") && !driver_value.toUpperCase().startsWith("NMNDD")) {
return driver_value;
}
}
}
if(!vga_driver_value.equals("")) {
return vga_driver_value;
} }
} catch (LWJGLException e) { } catch (LWJGLException e) {
LWJGLUtil.log("Exception occurred while querying registry: " + e); LWJGLUtil.log("Exception occurred while querying registry: " + e);
@ -362,9 +377,12 @@ final class WindowsDisplay implements DisplayImplementation {
public String getVersion() { public String getVersion() {
String driver = getAdapter(); String driver = getAdapter();
if (driver != null) { if (driver != null) {
WindowsFileVersion version = nGetVersion(driver + ".dll"); String[] drivers = driver.split(",");
if (version != null) if(drivers.length>0) {
return version.toString(); WindowsFileVersion version = nGetVersion(drivers[0] + ".dll");
if (version != null)
return version.toString();
}
} }
return null; return null;
} }