diff options
-rw-r--r-- | Sysinfo/SystemInfo.cs | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/Sysinfo/SystemInfo.cs b/Sysinfo/SystemInfo.cs index e4bfa5d..840c9d2 100644 --- a/Sysinfo/SystemInfo.cs +++ b/Sysinfo/SystemInfo.cs @@ -336,6 +336,7 @@ namespace Sysinfo { String temp; Boolean xorgB = false; + int index; try { @@ -345,17 +346,40 @@ namespace Sysinfo { while ( xorgB == false ) { temp = textread.ReadLine(); + + // EOF + if (temp == null) { + + break; + } + + // Blank line + if (temp.Trim().Length == 0) { + + continue; + } //version - if ( temp.StartsWith("X Window System Version")) { - - system_xorg = temp.Remove(0, 24); + index = temp.IndexOf("X Window System Version"); + + if (index >= 0 && system_xorg == "unknown") { + + system_xorg = temp.Substring(index + 24); + } + + index = temp.IndexOf("X.Org X Server"); + + if (index >= 0 && system_xorg == "unknown") { + + system_xorg = temp.Substring(index + 15); } //build date - if ( temp.StartsWith("Build Date")) { - - system_xorg = system_xorg + " (" + temp.Remove(0, 12) + ")"; + index = temp.IndexOf("Build Date"); + + if (index >= 0) { + + system_xorg = system_xorg + " (" + temp.Substring(index + 12) + ")"; xorgB = true; } |