Link to home
Start Free TrialLog in
Avatar of Haggard1
Haggard1

asked on

Change Windows XP Desktop Theme using ThemeUI.dll functions

Hi,

I want to be able to change the Windows XP Desktop theme (Not Current App) using any possible methods. I have found out that ThemeUI.dll controls this and also provides the preview window when a theme is selected, MS have not published the Function calls for this dll and information is all but non existant on google and the developer web sites. I did find this post on Experts Exchange but have been unsuccessful at gettig it to work,

https://www.experts-exchange.com/questions/21172764/Change-XP-Theme.html

The reason I wish to do this is so that I can provide several corporate themes for my company whilst stopping users from being able to install any themes that have not been approved. Group policy is not an option as it only disables the theme tab and forces a specific theme.

Any help on this would be greatly appreciated, I will give 500 points to anyone who can resolve this issue...
Avatar of Michael Pfister
Michael Pfister
Flag of Germany image

you can just call a theme by "running" it, the shell takes care of the rest.

i.e. in VBS set the classic style :

------ cut and save as ChgTheme.vbs -------------
set shell=createobject("wscript.shell")
shell.run """C:\Windows\Resources\Themes\Windows Classic.theme"""
WScript.Sleep 1000
shell.sendkeys "{ENTER}"
wscript.quit
---------------------------------------------------------
Disadvantage: a dialog box pops up for a few seconds, but the scripts sends an enter key to close it. A user could click somewhere else and the enter key goes to the wrong place.

Hope this helps.

Michael
Avatar of Haggard1
Haggard1

ASKER

Unfortunately this won't work as Group Policy will be enabled which will disable the Themes dialogue page.
I couldn't find anything regarding an API for ThemeUI.dll ... the only thing where you could start is modify the registry. The regfile you see here will switch the user from classic to Luna style, but only after logoff/logon.
So you could export the settings for the different styles you want to offer, let the user select one, import the according registry entries and tell the user to log off and log on again.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager]
"ThemeActive"="1"
"LoadedBefore"="1"
"LastUserLangID"="1031"
"DllName"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,\
  74,00,25,00,5c,00,72,00,65,00,73,00,6f,00,75,00,72,00,63,00,65,00,73,00,5c,\
  00,54,00,68,00,65,00,6d,00,65,00,73,00,5c,00,6c,00,75,00,6e,00,61,00,5c,00,\
  6c,00,75,00,6e,00,61,00,2e,00,6d,00,73,00,73,00,74,00,79,00,6c,00,65,00,73,\
  00,00,00
"ColorName"="NormalColor"
"SizeName"="NormalSize"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes]
"InstallTheme"=hex(2):25,00,52,00,65,00,73,00,6f,00,75,00,72,00,63,00,65,00,44,\
  00,69,00,72,00,25,00,5c,00,74,00,68,00,65,00,6d,00,65,00,73,00,5c,00,4c,00,\
  75,00,6e,00,61,00,2e,00,74,00,68,00,65,00,6d,00,65,00,00,00
"InstallVisualStyle"=hex(2):25,00,52,00,65,00,73,00,6f,00,75,00,72,00,63,00,65,\
  00,44,00,69,00,72,00,25,00,5c,00,74,00,68,00,65,00,6d,00,65,00,73,00,5c,00,\
  4c,00,75,00,6e,00,61,00,5c,00,4c,00,75,00,6e,00,61,00,2e,00,6d,00,73,00,73,\
  00,74,00,79,00,6c,00,65,00,73,00,00,00
"InstallVisualStyleColor"="NormalColor"
"InstallVisualStyleSize"="NormalSize"
"SetupVersion"="7"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\DefaultVisualStyleOff]
"InstallVisualStyle"=hex(2):00,00
"InstallVisualStyleColor"="Windows Standard"
"InstallVisualStyleSize"="Normal"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\DefaultVisualStyleOn]
"InstallVisualStyle"=hex(2):25,00,52,00,65,00,73,00,6f,00,75,00,72,00,63,00,65,\
  00,44,00,69,00,72,00,25,00,5c,00,74,00,68,00,65,00,6d,00,65,00,73,00,5c,00,\
  4c,00,75,00,6e,00,61,00,5c,00,4c,00,75,00,6e,00,61,00,2e,00,6d,00,73,00,73,\
  00,74,00,79,00,6c,00,65,00,73,00,00,00
"InstallVisualStyleColor"="NormalColor"
"InstallVisualStyleSize"="NormalSize"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\LastTheme]
"ThemeFile"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,\
  74,00,25,00,5c,00,72,00,65,00,73,00,6f,00,75,00,72,00,63,00,65,00,73,00,5c,\
  00,54,00,68,00,65,00,6d,00,65,00,73,00,5c,00,4c,00,75,00,6e,00,61,00,2e,00,\
  74,00,68,00,65,00,6d,00,65,00,00,00
"Wallpaper"=hex(2):00,00
"DisplayName of Modified"=""
ASKER CERTIFIED SOLUTION
Avatar of Michael Pfister
Michael Pfister
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi MPFISTER,

When I run the code I get and error Permission denied:'Length' Line:10 Char:9 which is line For i = 0 to objMGR.Length-1 for me...

I'm a local Admin on the box I'm on any idea's, you ran this and it worked?

Cheers

This is strange: on the box I wrote this script it worked just fine. On my box at home it displays the same error ...
I found it: my machine at home has XP SP2 on it, the machine the script worked before had XP SP1.

I renamed C:\WINDOWS\system32\themeui.dll on my home machine and replaced it with the themeui.dll from a Windows XP SP1 CD and the script worked!
I have no idea what could cause this...




Hi again,

Thanks for your help so far ; )

I've been looking at XP SP2 security, I think it might be to do with it not running as a system account or in the right security context. Any idea's...
I've opened another question if you want to have a crack a the points available, it's another 500 : )

https://www.experts-exchange.com/questions/21398325/Windows-XP-SP2-Access-Denied-Error-when-accessing-ThemeUI-dll-function.html 
Thanks for the points, Haggard1.
I've already looked at DCOM security, file security and registry security, I think somethings messed up with SP2s  ThemeUI.dll. I'd like to ask MS but the API is not officially supported (nothing on MSDN).
dosen't seem better with sp3 either.

http://www.microsoft.com/downloads/details.aspx?FamilyId=114F3599-12AF-42B2-AAB1-B969A62C68A7&displaylang=en

anyone got a better solution, that does not require a dll change?

I have experiented with some windows python api to custimize some of the settings, but I met the wall. the api dosent seem to work.
https://www.experts-exchange.com/questions/23238537/customizing-windows-turning-off-screensaver-and-set-winxp-to-run-with-effects-off.html