Question

I want to get a list of information (with filename and real theme name) of the installed AERO themes in a Windows 7 OS.

Also I need to change the current theme to one of the installed themes, but without using process.start(ThemeFile) because the personalization panel opens when I try that...

I know here is the installed theme files to get the filenames: "C:\Windows\Resources\Themes"

But I'm asking if exist a better way than listing the file content of that dir 'cause I need the real names too, and I want to know how to change the current theme to other without opening the personalization panel.

An example of this... I have only two Aero themes on my OS.

The filenames are:

Aero.theme
Concave_seven.theme

But the theme names wich appears in the personalization panel are:

Windows 7
Concave 7

I want to retreive the filenames and real names to store it in a listbox to change the current theme for the desired theme.

Update,

What I've tried...

 ' Load theme names
 For Each Theme As System.IO.FileInfo In New System.IO.DirectoryInfo(Environment.GetEnvironmentVariable("windir") & "\Resources\Themes").GetFiles("*theme")
    ComboBox1.Items.Add(Theme.ToString.Substring(0, Theme.ToString.Length - 6))
 Next

' Change theme
' Process.start(ThemeFilename)
' rundll32.exe Shell32.dll,Control_RunDLL desk.cpl desk,@Themes /Action:OpenTheme /File:"C:\Windows\Resources\Themes\aero.theme"
Was it helpful?

Solution

Well like anybody knew how to change the current theme without opening the theme selector with rundll32 etc... then here we go my personal trick (which is not on google and anywhere, it's pure luck).

First step: disable DWMCOMPOSITION for example disabling the "Themes" service.

Second step: add a regkey to specify the desired new theme, specify the msstyles file, not the .theme file.

I do this with a personal func but you can get the idea:

Reg_Set_Value("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager", "DllName", "C:\windows\resources\themes\aero\aero.msstyles", Microsoft.Win32.RegistryValueKind.String)

Third step: Re-enable the DWM composition ("Themes" service).

Voilá!

UPDATE:

Also I noticed need to change this value to 0 before enabling the theme to ensure all the color schemes are updated:

Reg_Set_Value("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager", "LoadedBefore", "0", Microsoft.Win32.RegistryValueKind.String)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top