using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Programs_List
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string x = "";
string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))
{
foreach (string skName in rk.GetSubKeyNames())
{
using (RegistryKey sk = rk.OpenSubKey(skName))
{
try
{
var displayName = sk.GetValue("DisplayName");
var size = sk.GetValue("EstimatedSize");
if (displayName != null)
{
if (displayName.ToString() == "FortiClient")
{
//x = sk.ToString();
x = skName;
}
}
}
catch (Exception ex)
{ }
}
}
}
textBox1.Text = x;
}
}
}
========================================================================
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Programs_List
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void action_btn_get_Click(object sender, EventArgs e)
{
string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))
{
foreach (string skName in rk.GetSubKeyNames())
{
using (RegistryKey sk = rk.OpenSubKey(skName))
{
try
{
MessageBox.Show(sk.ToString());
var displayName = sk.GetValue("DisplayName");
var size = sk.GetValue("EstimatedSize");
ListViewItem item;
if (displayName != null)
{
if (size != null)
item = new ListViewItem(new string[] {displayName.ToString(),
size.ToString()});
else
item = new ListViewItem(new string[] { displayName.ToString() });
lstDisplayHardware.Items.Add(item);
}
}
catch (Exception ex)
{ }
}
}
label1.Text += " (" + lstDisplayHardware.Items.Count.ToString() + ")";
}
}
}
}
沒有留言:
張貼留言