MS 画图注册表设置不起作用



几年前,我编写了一个C程序,该程序可以使用0x0像素调色板打开Microsoft画图。 它在生成 Paint 之前在注册表中写入值。 我创建了一个 C# 版本:

using System;
using Microsoft.Win32;
namespace PaintZeroCanvas
{
class Program
{
static void Main(string[] args)
{
const string userRoot = "HKEY_CURRENT_USER";
const string subkey = "Software\Microsoft\Windows\CurrentVersion\Applets\Paint\View";
const string keyName = userRoot + "\" + subkey;
Registry.SetValue(keyName, "BMPWidth", 0);
Registry.SetValue(keyName, "BMPHeight", 0);
Registry.CurrentUser.Flush();
System.Diagnostics.Process.Start(Environment.SystemDirectory + "\mspaint.exe");
}
}
}

注册表已修改,但"画图"以以前保存的大小打开。 这些键名称也出现在HKEY_USERS中,但在那里也不起作用。 我拥有管理权限,对这两个位置具有完全控制访问权限,并尝试使用管理权限运行该应用程序。

如果我手动启动 Paint,更改调色板大小并关闭它,则值将写入这两个位置。

我正在运行64位Windows 10并使用Visual Studio 2015 Community版本,并使用.NET Framework 4.5.2。

我认为您需要打开64位注册表,如下所示:

在 64 位计算机上使用 C# 和"BUILD x86"进行注册表访问

注意:下面的代码未经测试!

using System;
using Microsoft.Win32;
namespace PaintZeroCanvas
{
class Program
{
static void Main(string[] args)
{
const string userRoot = "HKEY_CURRENT_USER";
const string subkey = "Software\Microsoft\Windows\CurrentVersion\Applets\Paint\View";
const string keyName = userRoot + "\" + subkey;
RegistryKey registryKey = 
RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, 
RegistryView.Registry64).OpenSubKey(keyName);

registryKey.SetValue("BMPWidth", 0);
registryKey.SetValue("BMPHeight", 0);
System.Diagnostics.Process.Start(Environment.SystemDirectory + "\mspaint.exe");
}
}
}

最新更新