VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

 

Code Snippets

  

VB.NET Source Code


Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 339,903 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,565 people online right now. Registration is fast and FREE... Join Now!




Get Windows Experience Index base score for Vista

Get a string representation of Vista's Windows Experience Index base score.

Submitted By: RodgerB
Actions:
Rating:
Views: 2,732

Language: VB.NET

Last Modified: January 1, 1970
Instructions: 1) Copy and paste this function into the Form's class. 2) Read how to call the function.

Snippet


  1. ''' <summary>
  2. ''' Gets the base score of a computer running Windows Vista or higher.
  3. ''' </summary>
  4. ''' <returns>The String Representation of Score, or False.</returns>
  5. ''' <remarks></remarks>
  6.  
  7. Public Function GetBaseScore() As String
  8.  
  9.     ' Check if the computer has a \WinSAT dir.
  10.     If System.IO.Directory.Exists("C:\Windows\Performance\WinSAT\DataStore") Then
  11.  
  12.         ' Our method to get the most recently updated score.
  13.         ' Because the program makes a new XML file on every update of the score,
  14.         ' we need to calculate the most recent, just incase the owner has upgraded.
  15.  
  16.         Dim Dir As New IO.DirectoryInfo("C:\Windows\Performance\WinSAT\DataStore")
  17.         Dim fileDir() As IO.FileInfo
  18.         Dim fileMostRecent As IO.FileInfo
  19.         Dim LastAccessTime As Date
  20.         Dim LastAccessPath As String = ""
  21.         fileDir = Dir.GetFiles
  22.  
  23.         ' Loop through the files in the \WinSAT dir to find the newest one.
  24.  
  25.         For Each fileMostRecent In fileDir
  26.             If fileMostRecent.LastAccessTime >= LastAccessTime Then
  27.                 LastAccessTime = fileMostRecent.LastAccessTime
  28.                 LastAccessPath = fileMostRecent.FullName
  29.             End If
  30.         Next
  31.  
  32.         ' Create an XmlTextReader instance.
  33.         Dim xmlReadScore As New System.Xml.XmlTextReader(LastAccessPath)
  34.  
  35.         ' Disable whitespace handling so we don't read over them
  36.         xmlReadScore.WhitespaceHandling = System.Xml.WhitespaceHandling.None
  37.  
  38.             ' We need to get to the 25th tag, "WinSPR".
  39.         For I As Integer = 0 To 26
  40.             xmlReadScore.Read()
  41.         Next
  42.  
  43.         ' Create a string variable, so we can clean up without any mishaps.
  44.         Dim SystemScore As String = xmlReadScore.ReadElementString("SystemScore")
  45.         ' Clean up.
  46.         xmlReadScore.Close()
  47.  
  48.         Return SystemScore ' Return the String representation of the Base Score.
  49.     End If
  50.    
  51.     ' Unsuccessful.
  52.     Return False
  53. End Function
  54.  
  55. ' How to call this function.
  56. ' (copy and paste this information into a subroutine).
  57. Dim BaseScore As String = GetBaseScore()
  58. MsgBox(BaseScore)

Copy & Paste


Comments

There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month