问候 SO 社区
我正在编写 ac# 程序来管理 uwfmgr 注册表排除项。
我执行以下命令。
uwfmgr registry get-exclusions.
之后,当我想读取注册表时,我收到一条异常消息:
没有更多数据可用。
此问题一直存在,直到下次重新启动。
我怀疑 uwfmgr 没有正确释放注册表项。
我做了一个最小的例子来演示这个错误。
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Win32;
namespace WindowsFormsApplication2
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
try
{
Process proc = new Process();
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.FileName = "C:\\Windows\\Sysnative\\uwfmgr.exe";
proc.StartInfo.Arguments = "registry get-exclusions";
proc.Start();
proc.WaitForExit();
string output = proc.StandardOutput.ReadToEnd();
string[] subkeys = Registry.LocalMachine.GetSubKeyNames();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
}
}
}
}
信息:
- CLR 是“.Net Framework 4.5”。
- 目标是“任何 CPU”。
- 执行系统为“Windows Embedded 8.1 Industry Pro”。
- 该架构是 64 位的。
现在,有什么方法可以强制 uwfmgr 释放注册表吗?
PS:这是我的第一篇文章。我试着按照规则发帖,但如果我忘记了什么,请提醒我。谢谢。