vb Code:
  1. Set WMIObjectSet = GetObject("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_PhysicalMedia")
  2. For Each wmiobject In WMIObjectSet
  3.     s = wmiobject.SerialNumber
  4.     sn = ""
  5.     If Not IsNull(s) Then
  6.     If Len(s) > 20 Then
  7.     For i = 1 To Len(s) Step 4   ' windows 7
  8.         sn = sn & Chr("&h" & Mid(s, i + 2, 2)) & Chr("&h" & Mid(s, i, 2))
  9.     Next
  10.     ElseIf Len(s) = 20 Then
  11.     For i = 1 To Len(s) Step 2   ' vista
  12.         sn = sn & Mid(s, i + 1, 1) & Mid(s, i, 1)
  13.     Next
  14.     Else: sn = s   ' where string returned directly
  15.     End If
  16.     MsgBox wmiobject.Tag & " : " & Trim(sn)
  17.     End If
  18. Next
  19. Set WMIObjectSet = Nothing
  20.  
  21. End Sub

And provide me the solution "api version that asks for elevation
you need to follow all instructions for adding manifests to your exe, these are discussed in many places in this forum, all apps should now have this to be vista and windows 7 aware, as this is not just some vb code, but requires a tutorial, you will need to research it