Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get settings for Windows XP Style (Windows and buttons)

Status
Not open for further replies.

aspnetvbnetnerd

Programmer
Feb 3, 2008
31
SE
Is there any possibility to get what the user has set for XP Style in
Control panel --> Display --> Appearance -- Windows XP Style (Windows and buttons)?

I kneed to get informatatio what they have choosen.
If they have Windows Classic Style or Windows XP Style
 
I solved my problem.

I thought I could post it if someone else was intrested

Code:
Dim StrSecurityID As String
Dim StrColorName As String

StrSecurityID = GetSecurityID()

' If this value exists then we know that the user has Windows XP Style in appearance
If (RegValue(RegistryHive.CurrentUser, _
             "Software\Microsoft\Windows\CurrentVersion\ThemeManager", _
             "DllName")) <> "" Then

    'Now get what color name
    StrColorName = RegValue(RegistryHive.CurrentUser, _
                            "Software\Microsoft\Windows\CurrentVersion\ThemeManager", _
                            "ColorName")

    UserWindowsXPStyle = StrColorName

End If

Select Case UserWindowsXPStyle

    Case "NormalColor"

    Case "Metallic"

    Case "HomeStead"
        
    Case Else

End Select

Code:
Public Class Registry

    Public Shared Function RegValue(ByVal Hive As RegistryHive, _
                             ByVal Key As String, _
                             ByVal ValueName As String, _
                             Optional ByRef ErrInfo As String = "") As String

        Dim objParent As RegistryKey
        Dim objSubkey As RegistryKey
        Dim sAns As String = ""

        Select Case Hive
            Case RegistryHive.ClassesRoot
                objParent = Microsoft.Win32.Registry.ClassesRoot
            Case RegistryHive.CurrentConfig
                objParent = Microsoft.Win32.Registry.CurrentConfig
            Case RegistryHive.CurrentUser
                objParent = Microsoft.Win32.Registry.CurrentUser
            Case RegistryHive.DynData
                objParent = Microsoft.Win32.Registry.DynData
            Case RegistryHive.LocalMachine
                objParent = Microsoft.Win32.Registry.LocalMachine
            Case RegistryHive.PerformanceData
                objParent = Microsoft.Win32.Registry.PerformanceData
            Case RegistryHive.Users
                objParent = Microsoft.Win32.Registry.Users

        End Select

        Try
            objSubkey = objParent.OpenSubKey(Key)
            'if can't be found, object is not initialized
            If Not objSubkey Is Nothing Then
                sAns = CType((objSubkey.GetValue(ValueName)), String)
            End If

        Catch ex As System.Exception

            ErrInfo = ex.Message
        Finally

            'if no error but value is empty, populate errinfo
            If ErrInfo = "" And sAns = "" Then
                ErrInfo = _
                   "No value found for requested registry key"
            End If
        End Try

        Return sAns

    End Function

    Public Shared Function GetSecurityID() As String

        Dim Id As System.Security.Principal.WindowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent()
        Dim SecurityID As String = Id.User.AccountDomainSid.ToString()

        Return Id.User.Value

    End Function

End Class
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top