Get Modern UI theme colour manually - winapi

is there any way to find out the current theme color set for the Modern UI? A WinAPI function or registry value would be the best possible solution for me.
By current theme color i mean this.

There's a private function called GetImmersiveUserColorSetPreference in UxTheme.dll. If you set the first parameter to true, it should use the value from the registry that GameScripting mentioned (and notify the system of the change).
I wrote about retrieving immersive/modern/metro colours here. Keep in mind that you won't be able to use these undocumented functions in WinRT Windows Store Apps, since they'll fail certification.

After reverse engeneeing my system using procmon.exe, I've figured out that the registry key under the path HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Accent\ColorSet_Version3 seems to be the selected color.
I can read and write to it using the registry editor (regedit.exe) and all changes get applied immediately.
EDIT: After some further research, it seems to be read only, changed don't get applied "anymore". There seems to be anything at path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SystemProtectedUserData\S-1-5-21-3552576858-2522621019-3615910227-1001\AnyoneRead\Colors\ImmersiveColorIndex_Version3 but I can't manage to change the value (even with admin rights)

Related

I am editing mouse settings in the registry but they seem to do nothing

I have made a program to change the mouse sensivity in the same way as you can do it with the Control Panel.
The changes are made in the registry, the keys at HKEY_CURRENT_USER\Control Panel\Mouse and they are in fact done (I have checked them from regedit.exe) but the mouse works as if this changes are not made. In other words, the changes do not take any effect, they only do if you use the control panel. Why do they not take effect?
Windows registry isn't something that is refreshed all the time. The changes you made will be applied after the current user (that's why it's HKEY_CURRENT_USER) logs in again, or as you said after using control panel, which will read the registry. I don't know, what language your program is written in, but you should check out this link: "https://msdn.microsoft.com/en-us/library/ms724947.aspx"
In general, tweaking registry settings directly is unsupported, especially when there's an API to tweak the setting. In this case, the API is SystemParametersInfo. In particular, you need to use the SPI_SETMOUSESPEED as the argument for the uiAction parameter.
In other words, the changes do not take any effect, they only do if you use the control panel. Why do they not take effect?
Because there's often a little more to it than setting the value in the registry. Often there is a notification that must be sent after changing the value in order to tell the all the other software on the machine to drop any cached values and replace them with the new value that's now in the registry. In many cases, the notification will be in the form of a broadcast message.
In the case of mouse driver settings, you probably need to use the SPIF_UPDATEINIFILE argument for the fWinIni parameter. You might also need to OR it with SPIF_SENDCHANGE to broadcast a WM_SETTINGCHANGE message, but I'm not sure about that.

Windows PaintDesktopVersion

I am running Win7 and wish to change the build identifier displayed when setting HKCU\Control Panel\Desktop\PaintDesktopVersion to 1.
Is there a possibility to change this text, or to add to it (for example a name of the personal computer or a name of the user)?
Like David said, the string is hardcoded. The good thing is, there already exists a great utility that adds text to the wallpaper.
There's no API to control what gets displayed. You can hack the resources of user32.dll.mui to change the text if that's the kind of thing you like doing. Modifying the wallpaper would be a more reasonable approach in my view.

Where does Windows store its "Open With" settings?

I'm trying to programmatically check file associations by the file extension (for example .jnlp files). I keep reading that
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JNLPFile\Shell\Open\Command
is the Registry key to check. However, if you change the association through Windows Explorer:
Open With > Choose Program > (Always use the selected program)
the change isn't at all reflected in this Registry key. Where else is this information stored?
Take a look in:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\
and the sub-key of that is the extension you reassigned. Under that there will be the UserChoice and OpenWithList sub-keys which will contain your redefinition.
You may also want to read http://support.microsoft.com/kb/950505 which talks about your issue.
Update
As of Windows 8, life has gotten far more complicated. To create an extension association a custom hash needs to get calculated.
Fortunately, someone has reverse engineered the process and created a PowerShell script to do this without having to go through any GUI.
You can find it at the following GitHub link:
https://github.com/DanysysTeam/PS-SFTA
This is a two-part look-up.
First, you look up the default value of HKEY_CLASSES_ROOT\[file_extension]. For your extensions, .jnlp, the value is "JNLPFile". Let's call this the [file_descriptor].
Now you can look up the default value of HKEY_CLASSES_ROOT\[file_descriptor]\Shell\[action]\command (where [action] is the shell action you are interested in, e.g.: Open, Print, Edit, etc.).
On:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jnlp\OpenWithList
Tip: Edit>Find is pretty handy at these situations. :)

How does one detect when the wallpaper has changed (Windows XP or greater)?

I have figured out how to change the desktop wallpaper (there are dozens of examples on the Internet.)
One thing that still eludes me: how do I detect when the wallpaper has changed? (Say via the Display control panel or another program changing it.)
Add a message handler for WM_SETTINGCHANGE, SystemEvents.UserPreferenceChanged in .NET. Check if the wallpaper is still the same.
Here is an example in C# to retrieve the wallpaper. All you would need to add is some additional code to store the last wallpaper and check to see if it is different.
RegistryKey wallpaper = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop",false);
string wallpapername = wallpaper.GetValue("wallpaper").ToString();
wallpaper.Close();
If you were writing something in a non .net language you could use the Win32 API RegNotifyChangeKeyValue function to check to see if this value has changed:
HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper

Update desktop "show window contents while dragging" setting programatically

One of my programs seems to be changing the Display Properties > Appearance > Effects > Show window contents while dragging setting to off every few hours.
I'm not sure exactly which program, or when it happens. I have a number of programs that seem like likely culprits - wallpaper rotators, software for multiple monitors, multiple virual desktops and switching, and a few others.
I am just thinking to create a little batch script to run periodically and set the setting back to on.
Does anyone know how to do this in windows? I'm using xp pro sp3.
Thanks!
The best option is to do this programmatically using the supported API. i haven't tested this, but it should do the trick:
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS,
TRUE,
NULL,
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE)
You can use SPI_GETDRAGFULLWINDOWS to see if the the bit has been flipped to avoid unnecessarily triggering a WM_SETTINGCHANGE.
You can use RegMon to find the program that keeps changing your settings. Maybe that's a better start than hacking around it.
There is a simple and effective solution to this problem. In Notepad type the following lines :
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Control Panel\Desktop] "DragFullWindows"="1"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\DragFullWindows] "CheckedValue"=dword:00000001 "UncheckedValue"=dword:00000001
Save the file as "Show Window Contents.reg" Double clicking this file and restarting will cure the problem permanently. Post a message if you find this useful.
Aravind Banerjee
It seems the registry setting which controls that preference is HKCU\Control Panel\Desktop\DragFullWindows. You can read more about it here. However, trying it on my own computer does not register the change right away, so a batch script won't do it. You'll probably have to write a program to manipulate it using SystemParametersInfo(). You can pass it the SPI_SETDRAGFULLWINDOWS parameter. Here's a page explaining it more. Here's a page showing how to call it, albeit not for the same parameter.
I suspect it's kept in the registry - maybe [HKEY_CURRENT_USER\Control Panel\Desktop] - "DragFullWindows"?
It would be easy to flip the registry setting back to "1" every hour or so with a batch file.

Resources