0

我想获取 Windows 7 操作系统中已安装 AERO 主题的信息列表(带有文件名和真实主题名称)。

我还需要将当前主题更改为已安装的主题之一,但不要使用,process.start(ThemeFile)因为我尝试这样做时会打开个性化面板...

我知道这里是安装的主题文件来获取文件名:“C:\Windows\Resources\Themes”

但是我问是否存在比列出该目录的文件内容更好的方法,因为我也需要真实姓名,并且我想知道如何在不打开个性化面板的情况下将当前主题更改为其他主题。

这方面的一个例子......我的操作系统上只有两个 Aero 主题。

文件名是:

Aero.theme
Concave_seven.theme

但是个性化面板中出现的主题名称是:

Windows 7
Concave 7

我想检索文件名和真实姓名以将其存储在列表框中,以将当前主题更改为所需主题。

更新

我试过的...

 ' 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"
4

1 回答 1

0

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)
于 2013-04-29T01:10:10.430 回答