{"id":380,"date":"2010-06-26T20:21:18","date_gmt":"2010-06-26T17:21:18","guid":{"rendered":"http:\/\/www.notsayfam.com\/?p=380"},"modified":"2018-06-12T17:27:15","modified_gmt":"2018-06-12T15:27:15","slug":"vb-net-ile-registry-kullanarak-monitor-bilgilerini-goruntulemek","status":"publish","type":"post","link":"https:\/\/www.notsayfam.com\/?p=380","title":{"rendered":"vb.net ile registry kullanarak Monit\u00f6r Bilgilerini G\u00f6r\u00fcnt\u00fclemek"},"content":{"rendered":"<p>Envanter yaz\u0131l\u0131m\u0131na bir b\u00f6l\u00fcm daha ekledim. Bilgisayara ba\u011fl\u0131 olan Monit\u00f6r\u00fcn registry \u00fczerinde kay\u0131tl\u0131 olan EDID (Extended display identification data) bilgilerinden yararlanarak Serino,model,\u00fcretim tarihi,\u00f6l\u00e7\u00fcleri ve ka\u00e7 in\u00e7 oldu\u011fu gibi bilgilere eri\u015febiliyoruz. Detayl\u0131 bilgi i\u00e7in <a href=\"http:\/\/www.stellae.fr\/wiki\/_media\/efika_data:e-edid_implementation_guide_vesa.pdf?id=electronics%3Aefika_en&amp;cache=cache\">VESA E-EDID\u2122 Implementation Guide<\/a> \u0131 kullanabilirsiniz.<\/p>\n<p>Imports System.Management<br \/>\nImports System.Text<br \/>\nImports Microsoft.Win32<br \/>\nImports System.Net.NetworkInformation<br \/>\nPublic Class Form1<br \/>\nDim strmodel As String = &#8220;&#8221;<br \/>\nDim strmodel2 As String = &#8220;&#8221;<br \/>\nDim strserino As String = &#8220;&#8221;<br \/>\nDim regedithex As String = &#8220;&#8221;<br \/>\nDim struretimhaftasi As String = &#8220;&#8221;<br \/>\nDim struretimyili As String = &#8220;&#8221;<br \/>\nDim strdikey, stryatay As Integer<br \/>\nDim strmonitorinc As Double<br \/>\nPrivate Function ByteArrayToString(ByVal ba As Byte()) As String<br \/>\nDim hex As New StringBuilder(ba.Length * 2)<br \/>\nFor Each b As Byte In ba<br \/>\nhex.AppendFormat(&#8220;{0:x2}&#8221;, b)<br \/>\nNext<br \/>\nReturn hex.ToString()<br \/>\nEnd Function<\/p>\n<p>G\u00fcncelleme: 26 Haziran 2010<br \/>\n<!--more--><br \/>\nPrivate Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click<br \/>\nstrmodel = &#8220;&#8221;<br \/>\nstrmodel2 = &#8220;&#8221;<br \/>\nstrserino = &#8220;&#8221;<br \/>\nregedithex = &#8220;&#8221;<br \/>\nDim host As String = InputBox(&#8220;L\u00fctfen M\u00f6nit\u00f6r\u00fcn\u00fc tespit etmek istedi\u011finiz host ad\u0131n\u0131 veya ip adresini giriniz:&#8221;, &#8220;Bilgisayar Giri\u015fi&#8221;)<br \/>\n&#8216;E\u011fer giri\u015f bo\u015f ge\u00e7ilirse local bilgisayar\u0131 alal\u0131m<br \/>\nIf host = &#8220;&#8221; Then host = &#8220;.&#8221;<br \/>\nIf host &lt;&gt; &#8220;.&#8221; Then<br \/>\nDim pingat As New Ping<br \/>\nDim pingsonuc As PingReply<br \/>\nTry<br \/>\npingsonuc = pingat.Send(host)<br \/>\nCatch ex As Exception<br \/>\nMsgBox(&#8220;Yazd\u0131\u011f\u0131n\u0131z bilgisayar ile ileti\u015fim kurulam\u0131yor&#8221; &amp; ex.Message)<br \/>\nExit Sub<br \/>\nEnd Try<\/p>\n<p>If pingsonuc.Status &lt;&gt; IPStatus.Success Then<br \/>\nMsgBox(&#8220;Yazd\u0131\u011f\u0131n\u0131z bilgisayar ile ileti\u015fim kurulam\u0131yor&#8221;)<br \/>\nExit Sub<br \/>\nEnd If<br \/>\nEnd If<\/p>\n<p>Dim MyReg As RegistryKey = RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, host)<br \/>\nDim Key As RegistryKey = MyReg.OpenSubKey _<br \/>\n(&#8220;SYSTEM\\CurrentControlSet\\Enum\\DISPLAY&#8221;, False)<br \/>\n&#8216;Display parametresinin alt\u0131ndaki t\u00fcm keyleri subkeynames dizisine at\u0131yoruz<br \/>\nDim SubKeyNames() As String = Key.GetSubKeyNames()<br \/>\nDim Index As Integer<br \/>\nDim Subkey As RegistryKey<br \/>\nDim dogrupath As String = &#8220;&#8221;<br \/>\nFor Index = 0 To Key.SubKeyCount &#8211; 1<br \/>\nTry<br \/>\n&#8216;Enum\\Display keyi alt\u0131ndaki t\u00fcm anahtarlar i\u00e7in yeni bir subkey olu\u015ftural\u0131m<br \/>\nDim Key2 As RegistryKey = MyReg.OpenSubKey(&#8220;SYSTEM\\CurrentControlSet\\Enum\\DISPLAY\\&#8221; _<br \/>\n+ SubKeyNames(Index), False)<br \/>\nDim SubKeyNames2() As String = Key2.GetSubKeyNames()<\/p>\n<p>For index2 As Integer = 0 To Key2.SubKeyCount &#8211; 1<br \/>\n&#8216;Birden fazla monit\u00f6r takm\u0131\u015fsan\u0131z e\u011fer \u00e7ok fazla subkey olu\u015fabilir<br \/>\n&#8216;Aktif olan monit\u00f6r i\u00e7in subkey alt\u0131nda Control isimli bir anahtar bulunmakta<\/p>\n<p>Subkey = MyReg.OpenSubKey(&#8220;SYSTEM\\CurrentControlSet\\Enum\\DISPLAY\\&#8221; _<br \/>\n+ SubKeyNames(Index) + &#8220;\\&#8221; + SubKeyNames2(index2) + &#8220;\\Control&#8221;, False)<br \/>\n&#8216;E\u011fer control isimli subkey yok ise bir sonraki keye gidelim<br \/>\nIf Subkey Is Nothing Then<br \/>\nGoTo sonraki<br \/>\nElse<br \/>\n&#8216;E\u011fer control mevcut ise Device Parameters alt\u0131ndaki EDID Reg_Binary de\u011ferine bak\u0131yoruz<br \/>\n&#8216;Monit\u00f6r \u00e7\u0131kart\u0131lm\u0131\u015f ise BAD_EDID anahtar\u0131 olu\u015fuyor.<\/p>\n<p>Subkey = MyReg.OpenSubKey(&#8220;SYSTEM\\CurrentControlSet\\Enum\\DISPLAY\\&#8221; _<br \/>\n+ SubKeyNames(Index) + &#8220;\\&#8221; + SubKeyNames2(index2) + &#8220;\\Device Parameters&#8221;, False)<br \/>\nDim bytes As Byte() = Subkey.GetValue(&#8220;EDID&#8221;, Nothing)<br \/>\nTry<br \/>\nIf bytes.Length &gt; 0 Then<br \/>\n&#8216;Byte olarak ald\u0131\u011f\u0131m\u0131z de\u011ferleri hex format\u0131na \u00e7evirelim<\/p>\n<p>regedithex = ByteArrayToString(bytes)<br \/>\n&#8216;MsgBox(regedithex)<br \/>\nstruretimhaftasi = System.Convert.ToInt32(Mid(regedithex, 33, 2), 16)<br \/>\nstruretimyili = CInt(System.Convert.ToInt32(Mid(regedithex, 35, 2), 16)) + 1990<\/p>\n<p>strdikey = CInt(System.Convert.ToInt32(Mid(regedithex, 43, 2), 16))<br \/>\nstryatay = CInt(System.Convert.ToInt32(Mid(regedithex, 45, 2), 16))<\/p>\n<p>strmonitorinc = (Math.Sqrt(strdikey * strdikey + stryatay * stryatay) \/ 2.54)<\/p>\n<p>Subkey = MyReg.OpenSubKey(&#8220;SYSTEM\\CurrentControlSet\\Enum\\DISPLAY\\&#8221; _<br \/>\n+ SubKeyNames(Index) + &#8220;\\&#8221; + SubKeyNames2(index2), False)<br \/>\n&#8216;E\u011fer monitorun windows s\u00fcr\u00fcc\u00fcs\u00fc y\u00fcklenmi\u015f ise modelini registry \u00fczerinden alal\u0131m<br \/>\nstrmodel2 = Subkey.GetValue(&#8220;DeviceDesc&#8221;)<br \/>\nEnd If<\/p>\n<p>Catch ex As Exception<br \/>\nEnd Try<br \/>\nEnd If<br \/>\nsonraki:<br \/>\nNext<br \/>\nCatch ex As Exception<\/p>\n<p>End Try<br \/>\nNext<\/p>\n<p>&#8216;000000ff den sonraki 14 karakter seri numaray\u0131 i\u00e7ermekte<br \/>\nDim serinoindex As Integer = InStr(regedithex, &#8220;000000ff&#8221;) + 8<br \/>\n&#8216;000000fc den sonra olan 14 karakter model numaras\u0131n\u0131 i\u00e7eriyor<br \/>\nDim modelindex As Integer = InStr(regedithex, &#8220;000000fc&#8221;) + 8<br \/>\nDim serinohex As String = Mid(regedithex, serinoindex, 28)<br \/>\nDim modelhex As String = Mid(regedithex, modelindex, 28)<\/p>\n<p>For y As Integer = 1 To Len(serinohex) Step 2<br \/>\nDim s As String<br \/>\nDim b As Byte<br \/>\nb = System.Convert.ToByte((Mid(serinohex, y, 2)), 16)<br \/>\ns = Chr(b)<br \/>\nIf Asc(s) &lt;&gt; 0 And (Asc(s) &gt; 47 And Asc(s) &lt; 126) Then<br \/>\nstrserino += s<br \/>\nEnd If<br \/>\nNext y<br \/>\nFor y As Integer = 1 To Len(modelhex) Step 2<br \/>\nDim s As String<br \/>\nDim b As Byte<br \/>\nb = System.Convert.ToByte((Mid(modelhex, y, 2)), 16)<br \/>\ns = Chr(b)<br \/>\nIf Asc(s) &lt;&gt; 0 And (Asc(s) &gt; 47 And Asc(s) &lt; 126) Then<br \/>\nstrmodel += s<br \/>\nEnd If<br \/>\nNext y<br \/>\nDim alinanhost As String = &#8220;&#8221;<br \/>\nIf host = &#8220;.&#8221; Then<br \/>\nalinanhost = &#8220;Yerel bilgisayar&#8221;<br \/>\nElse<br \/>\nalinanhost = host<br \/>\nEnd If<\/p>\n<p>MsgBox(&#8220;Monit\u00f6r Bilgileri Al\u0131nan Bilgisayar: &#8221; + alinanhost + vbCrLf + _<br \/>\n&#8220;Monitor Registry Modeli: &#8221; &amp; strmodel2 &amp; vbCrLf &amp; _<br \/>\n&#8220;Monit\u00f6r Device Modeli: &#8221; &amp; Trim(strmodel) &amp; vbCrLf &amp; _<br \/>\n&#8220;Monit\u00f6r Seri Numaras\u0131: &#8221; &amp; strserino &amp; vbCrLf &amp; _<br \/>\n&#8220;\u00dcretim Haftas\u0131: &#8221; &amp; struretimhaftasi &amp; vbCrLf &amp; _<br \/>\n&#8220;\u00dcretim Y\u0131l\u0131: &#8221; &amp; struretimyili &amp; vbCrLf &amp; _<br \/>\n&#8220;Monit\u00f6r Dikey Boyutu (cm): &#8221; &amp; strdikey &amp; vbCrLf &amp; _<br \/>\n&#8220;Monit\u00f6r Yatay Boyutu (cm): &#8221; &amp; stryatay &amp; vbCrLf &amp; _<br \/>\n&#8220;Monit\u00f6r Boyutu (inc): &#8221; &amp; Format(strmonitorinc, &#8220;##.##&#8221;))<br \/>\nEnd Sub<br \/>\nEnd Class<\/p>\n<p>Vs2005 \u00d6rnek Uygulamas\u0131n\u0131 \u0130ndirmek i\u00e7in <a href=\"http:\/\/www.notsayfam.com\/?download=514\" target=\"_blank\" rel=\"noopener\">t\u0131klay\u0131n\u0131z<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>vb.net ile registry kullanarak Monit\u00f6r Bilgilerini G\u00f6r\u00fcnt\u00fclemek<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,13],"tags":[],"class_list":["post-380","post","type-post","status-publish","format-standard","hentry","category-programlama","category-vb-net"],"_links":{"self":[{"href":"https:\/\/www.notsayfam.com\/index.php?rest_route=\/wp\/v2\/posts\/380","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.notsayfam.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.notsayfam.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.notsayfam.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.notsayfam.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=380"}],"version-history":[{"count":9,"href":"https:\/\/www.notsayfam.com\/index.php?rest_route=\/wp\/v2\/posts\/380\/revisions"}],"predecessor-version":[{"id":576,"href":"https:\/\/www.notsayfam.com\/index.php?rest_route=\/wp\/v2\/posts\/380\/revisions\/576"}],"wp:attachment":[{"href":"https:\/\/www.notsayfam.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.notsayfam.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.notsayfam.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}