这些代码允许我访问注册表并获取不可读格式的 lastvisitedMRU 值。我在这里所做的是将它们转换为可读的格式。我将它们放在一个数组中并将它们输出到控制台。
输出如下:
C : \ P r o g r a m F i l e s \ i P o d \ f i l e . t x t
如何删除中间的间距?
提前致谢。
try
{
RegistryKey rk = Registry.CurrentUser;
rk = rk.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedMRU", false);
PrintKeys(rk);
}
catch (Exception MyError)
{
Console.WriteLine("An error has occurred: " + MyError.Message);
}
}
static void PrintKeys(RegistryKey rk)
{
if (rk == null)
{
Console.WriteLine("No specified registry key!");
return;
}
String[] names = rk.GetValueNames();
Console.WriteLine("Subkeys of " + rk.Name);
Console.WriteLine("-----------------------------------------------");
foreach (String s in names)
{
try
{
if (s == "MRUList")
{
continue;
}
else
{
try
{
Byte[] byteValue = (Byte[])rk.GetValue(s);
string str = BitConverter.ToString(byteValue).Replace("00", "");
str = BitConverter.ToString(byteValue).Replace("-", "");
//str binry AND VAR CONVERTED TEXT
Console.WriteLine(s + " Contains the value of : " + str);
StringBuilder sb = new StringBuilder();
for (int i = 0; i <= str.Length - 2; i += 2)
{
sb.Append(Convert.ToString(Convert.ToChar(Int32.Parse(str.Substring(i, 2), System.Globalization.NumberStyles.HexNumber))));
}
String val = Convert.ToString(sb).Replace(" ", "");
Console.WriteLine(s + " Contains the value of : " + val);
}
catch (Exception Errors)
{
Console.WriteLine("An error has occurred: " + Errors.Message);
}
}
//rk.Close();
}
catch (Exception MyError)
{
Console.WriteLine("An error has occurred: " + MyError.Message);
}
Console.WriteLine("-----------------------------------------------");
//rk.Close();
}