change the Screen Resolution?

Mr_Braytee

New member
Joined
Jun 8, 2006
Messages
2
Programming Experience
1-3
icon5.gif
[02/03] Problem to access to registry
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
second I call the function at the event load in the main form:


'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
So What is the problem or any idea to solve this problem
best regards
Mr Braytee
 
Last edited by a moderator:
You need to use the ChangeDisplaySettings API method, here is one example, it's in VB6 because I didn't find one translated to VB.Net but it's not a big deal to make work in VB.Net "How to change the Screen Resolution" http://abstractvb.com/code.asp?A=947
 
Back
Top