Envanter yazılımına bir bölüm daha ekledim. Bilgisayara bağlı olan Monitörün registry üzerinde kayıtlı olan EDID (Extended display identification data) bilgilerinden yararlanarak Serino,model,üretim tarihi,ölçüleri ve kaç inç olduğu gibi bilgilere erişebiliyoruz. Detaylı bilgi için VESA E-EDID™ Implementation Guide ı kullanabilirsiniz.
Imports System.Management
Imports System.Text
Imports Microsoft.Win32
Imports System.Net.NetworkInformation
Public Class Form1
Dim strmodel As String = “”
Dim strmodel2 As String = “”
Dim strserino As String = “”
Dim regedithex As String = “”
Dim struretimhaftasi As String = “”
Dim struretimyili As String = “”
Dim strdikey, stryatay As Integer
Dim strmonitorinc As Double
Private Function ByteArrayToString(ByVal ba As Byte()) As String
Dim hex As New StringBuilder(ba.Length * 2)
For Each b As Byte In ba
hex.AppendFormat(“{0:x2}”, b)
Next
Return hex.ToString()
End Function
Güncelleme: 26 Haziran 2010
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
strmodel = “”
strmodel2 = “”
strserino = “”
regedithex = “”
Dim host As String = InputBox(“Lütfen Mönitörünü tespit etmek istediğiniz host adını veya ip adresini giriniz:”, “Bilgisayar Girişi”)
‘Eğer giriş boş geçilirse local bilgisayarı alalım
If host = “” Then host = “.”
If host <> “.” Then
Dim pingat As New Ping
Dim pingsonuc As PingReply
Try
pingsonuc = pingat.Send(host)
Catch ex As Exception
MsgBox(“Yazdığınız bilgisayar ile iletişim kurulamıyor” & ex.Message)
Exit Sub
End Try
If pingsonuc.Status <> IPStatus.Success Then
MsgBox(“Yazdığınız bilgisayar ile iletişim kurulamıyor”)
Exit Sub
End If
End If
Dim MyReg As RegistryKey = RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, host)
Dim Key As RegistryKey = MyReg.OpenSubKey _
(“SYSTEM\CurrentControlSet\Enum\DISPLAY”, False)
‘Display parametresinin altındaki tüm keyleri subkeynames dizisine atıyoruz
Dim SubKeyNames() As String = Key.GetSubKeyNames()
Dim Index As Integer
Dim Subkey As RegistryKey
Dim dogrupath As String = “”
For Index = 0 To Key.SubKeyCount – 1
Try
‘Enum\Display keyi altındaki tüm anahtarlar için yeni bir subkey oluşturalım
Dim Key2 As RegistryKey = MyReg.OpenSubKey(“SYSTEM\CurrentControlSet\Enum\DISPLAY\” _
+ SubKeyNames(Index), False)
Dim SubKeyNames2() As String = Key2.GetSubKeyNames()
For index2 As Integer = 0 To Key2.SubKeyCount – 1
‘Birden fazla monitör takmışsanız eğer çok fazla subkey oluşabilir
‘Aktif olan monitör için subkey altında Control isimli bir anahtar bulunmakta
Subkey = MyReg.OpenSubKey(“SYSTEM\CurrentControlSet\Enum\DISPLAY\” _
+ SubKeyNames(Index) + “\” + SubKeyNames2(index2) + “\Control”, False)
‘Eğer control isimli subkey yok ise bir sonraki keye gidelim
If Subkey Is Nothing Then
GoTo sonraki
Else
‘Eğer control mevcut ise Device Parameters altındaki EDID Reg_Binary değerine bakıyoruz
‘Monitör çıkartılmış ise BAD_EDID anahtarı oluşuyor.
Subkey = MyReg.OpenSubKey(“SYSTEM\CurrentControlSet\Enum\DISPLAY\” _
+ SubKeyNames(Index) + “\” + SubKeyNames2(index2) + “\Device Parameters”, False)
Dim bytes As Byte() = Subkey.GetValue(“EDID”, Nothing)
Try
If bytes.Length > 0 Then
‘Byte olarak aldığımız değerleri hex formatına çevirelim
regedithex = ByteArrayToString(bytes)
‘MsgBox(regedithex)
struretimhaftasi = System.Convert.ToInt32(Mid(regedithex, 33, 2), 16)
struretimyili = CInt(System.Convert.ToInt32(Mid(regedithex, 35, 2), 16)) + 1990
strdikey = CInt(System.Convert.ToInt32(Mid(regedithex, 43, 2), 16))
stryatay = CInt(System.Convert.ToInt32(Mid(regedithex, 45, 2), 16))
strmonitorinc = (Math.Sqrt(strdikey * strdikey + stryatay * stryatay) / 2.54)
Subkey = MyReg.OpenSubKey(“SYSTEM\CurrentControlSet\Enum\DISPLAY\” _
+ SubKeyNames(Index) + “\” + SubKeyNames2(index2), False)
‘Eğer monitorun windows sürücüsü yüklenmiş ise modelini registry üzerinden alalım
strmodel2 = Subkey.GetValue(“DeviceDesc”)
End If
Catch ex As Exception
End Try
End If
sonraki:
Next
Catch ex As Exception
End Try
Next
‘000000ff den sonraki 14 karakter seri numarayı içermekte
Dim serinoindex As Integer = InStr(regedithex, “000000ff”) + 8
‘000000fc den sonra olan 14 karakter model numarasını içeriyor
Dim modelindex As Integer = InStr(regedithex, “000000fc”) + 8
Dim serinohex As String = Mid(regedithex, serinoindex, 28)
Dim modelhex As String = Mid(regedithex, modelindex, 28)
For y As Integer = 1 To Len(serinohex) Step 2
Dim s As String
Dim b As Byte
b = System.Convert.ToByte((Mid(serinohex, y, 2)), 16)
s = Chr(b)
If Asc(s) <> 0 And (Asc(s) > 47 And Asc(s) < 126) Then
strserino += s
End If
Next y
For y As Integer = 1 To Len(modelhex) Step 2
Dim s As String
Dim b As Byte
b = System.Convert.ToByte((Mid(modelhex, y, 2)), 16)
s = Chr(b)
If Asc(s) <> 0 And (Asc(s) > 47 And Asc(s) < 126) Then
strmodel += s
End If
Next y
Dim alinanhost As String = “”
If host = “.” Then
alinanhost = “Yerel bilgisayar”
Else
alinanhost = host
End If
MsgBox(“Monitör Bilgileri Alınan Bilgisayar: ” + alinanhost + vbCrLf + _
“Monitor Registry Modeli: ” & strmodel2 & vbCrLf & _
“Monitör Device Modeli: ” & Trim(strmodel) & vbCrLf & _
“Monitör Seri Numarası: ” & strserino & vbCrLf & _
“Üretim Haftası: ” & struretimhaftasi & vbCrLf & _
“Üretim Yılı: ” & struretimyili & vbCrLf & _
“Monitör Dikey Boyutu (cm): ” & strdikey & vbCrLf & _
“Monitör Yatay Boyutu (cm): ” & stryatay & vbCrLf & _
“Monitör Boyutu (inc): ” & Format(strmonitorinc, “##.##”))
End Sub
End Class
Vs2005 Örnek Uygulamasını İndirmek için tıklayınız.