Mr_Braytee
New member
- Joined
- Jun 8, 2006
- Messages
- 2
- Programming Experience
- 1-3

hi to all
I want from my software to access to the registry in win xp to change the resolution directly to 800*600 at the load event in the main form
first I create a class for registry:
VB.NET:
Imports System
Imports Microsoft.Win32
Public Class RegistryAccess
Public ReadOnly Property HkeyCurrentConfig() As RegistryKey
Get
Return Registry.CurrentConfig
End Get
End Property
Public Shared Function SetRegistryValue(ByVal root As RegistryKey, _
ByVal path As String, ByVal keyName As String, ByVal val As Object) As Boolean
Try
Dim rootKey As RegistryKey = root
Dim searchKey As RegistryKey = root.OpenSubKey(path)
'Return searchKey.GetValue(keyName)
searchKey.SetValue(keyName, val)
Return True
Catch e As Exception
Return False
End Try
End Function
End Class
'I call the function from the class at the loading of the main form
VB.NET:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim regTest As New RegistryAccess
Dim xRes As Integer = 800
Dim yRes As Integer = 600
regTest.SetRegistryValue(regTest.HkeyCurrentConfig, _
"HKEY_CURRENT_CONFIG\System\CurrentControlSet\Control\VIDEO\{4BD04266-4AE9-48FF-B285-1EFCF47DC5C7}\0000\Mon00000110", _
"DefaultSettings.XResolution", xRes)
regTest.SetRegistryValue(regTest.HkeyCurrentConfig, _
"HKEY_CURRENT_CONFIG\System\CurrentControlSet\Control\VIDEO\{4BD04266-4AE9-48FF-B285-1EFCF47DC5C7}\0000\Mon00000110", _
"DefaultSettings.YResolution", yRes)
End Sub
best regards
Mr Braytee
Last edited by a moderator: