I am trying to get the last used Keyboard layout by the current user by reading the HKCU\Keyboard Layout\Preload\1
from my application. Every time the default keyboard is changed in the control panel I can see that the value at the above location changes(I can see this by having RegEdit open). But for some reason my application still reads the old value without taking into the account the latest refresh which I can see on RegEdit.
string KeyboardLayoutRegKey = "Keyboard Layout\\Preload";
pLastUsedKeyboard = RegistryAccessor.CurrentUser.OpenSubKey(KeyboardLayoutRegKey).GetValue("1").ToString(),
When I change the value from English-US to French the hexadecimal value in the registry changes from 409 to 40c which I can see in RegEdit, but my application still reads it as 409 until I reboot? Why does it do that? My application is targeted to AnyCPU.
EDIT
/// <summary>
/// Provides access to the registry.
/// </summary>
public class RegistryAccessor : IRegistryAccessor
{
/// <summary>
/// Contains information about the current user preferences. This field reads the Windows registry base key HKEY_CURRENT_USER.
/// </summary>
public IRegistryKey CurrentUser
{
get
{
return new RegistryKeyWrapper(Registry.CurrentUser);
}
}
/// <summary>
/// Contains the configuration data for the local machine. This field reads the Windows registry base key HKEY_LOCAL_MACHINE.
/// </summary>
public IRegistryKey LocalMachine
{
get
{
return new RegistryKeyWrapper(Registry.LocalMachine);
}
}
/// <summary>
/// Contains the configuration data for the Users. This field reads the Windows registry base key HKEY_USERS.
/// </summary>
public IRegistryKey Users
{
get
{
return new RegistryKeyWrapper(Registry.Users);
}
}
}