Reputation: 229
This is my current code, it works but it restarts the Explorer process and that's kinda weird.
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Win32;
namespace MyApp
{
class Program
{
static async Task Main(string[] args)
{
ShowSmallTaskbarIcons();
// ShowLargeTaskbarIcons();
Console.WriteLine("Press a key to exit...");
Console.ReadKey();
}
static void ShowSmallTaskbarIcons()
{
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarSmallIcons", "1", RegistryValueKind.DWord);
RefreshExplorer();
}
static void ShowLargeTaskbarIcons()
{
var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", writable: true);
key.DeleteValue("TaskbarSmallIcons", throwOnMissingValue: false);
key.Close();
RefreshExplorer();
}
static void RefreshExplorer()
{
Process.Start("taskkill.exe", "/f /im explorer.exe");
Thread.Sleep(2000);
Process.Start("explorer.exe");
Thread.Sleep(10000);
}
}
}
I would like to do the same as with the "Use small taskbar buttons" toggle switch from Settings.
How to do the same with C#?
Upvotes: 0
Views: 697
Reputation: 2568
How to change Windows 10 taskbar icon size programmatically
This post has an example about how to send WM_SETTINGCHANGE message in c++.
However, there is no easy way to do it in c# wrapped function. You have to do it through p/invoke
Following post will help you do it in c#
convert C++ code to C#: SendMessageTimeout()
Upvotes: 2