En iyi yanıtlayıcılar
Bilgisayarda kurulu bir programın dosya yolunu öğrenmek.

Soru
-
Arkadaşlar bir program yapıyorum bilgisayara yuklu programların kontrolü ile ilgili.forma bir combobox attım ve yüklü program ların adlarını combo box a çekebiliyorum ancak bu programların dosya yollarını nasıl öğrene bilirim onu bilmiyorum.Yardımcı olursanız cok sevinirim.Teşekkürler.
Yanıtlar
-
private string FindByDisplayName(RegistryKey parentKey, string name)
{
string[] nameList = parentKey.GetSubKeyNames();
for (int i = 0; i < nameList.Length; i++)
{
RegistryKey regKey = parentKey.OpenSubKey(nameList[i]);
try
{
if (regKey.GetValue("DisplayName").ToString() == name)
{
return regKey.GetValue("InstallLocation").ToString();
}
}
catch { }
}
return "";
}
RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");
string location = FindByDisplayName(regKey, "MSN");
MessageBox.Show(location);Kodlar alıntıdır.
Mantığına gelirsek,Windows ta yüklü programların listesi HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall anahtarından elde edilebilir.
sssa
- Düzenleyen Semih ARTAN 10 Nisan 2017 Pazartesi 16:07
- Yanıt Olarak İşaretleyen umut Çelik 11 Nisan 2017 Salı 12:19
-
protected SortedDictionary<string, string> programlar = null;
public SortedDictionary<string, string> Programlar
{
get
{
if (programlar == null)
{
programlar = new SortedDictionary<string, string>();
using (RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"))
{
foreach (string subKeyName in regKey.GetSubKeyNames())
{
using (RegistryKey subKey = regKey.OpenSubKey(subKeyName))
{
try
{
if (subKey.GetValue("DisplayName") != null && subKey.GetValue("InstallLocation") != null)
programlar.Add(subKey.GetValue("DisplayName").ToString(), subKey.GetValue("InstallLocation").ToString());
}
catch
{
}
}
}
}
}
return programlar;
}
}private void Form1_Load(object sender, EventArgs e)
{comboBox1.DataSource = new BindingSource(Programlar, null);
comboBox1.DisplayMember = "Key";
comboBox1.ValueMember = "Value";
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
label1.Text = comboBox1.SelectedValue;
}- Düzenleyen MuratAKSARAY 11 Nisan 2017 Salı 07:29
- Yanıt Olarak İşaretleyen umut Çelik 11 Nisan 2017 Salı 12:20
Tüm Yanıtlar
-
private string FindByDisplayName(RegistryKey parentKey, string name)
{
string[] nameList = parentKey.GetSubKeyNames();
for (int i = 0; i < nameList.Length; i++)
{
RegistryKey regKey = parentKey.OpenSubKey(nameList[i]);
try
{
if (regKey.GetValue("DisplayName").ToString() == name)
{
return regKey.GetValue("InstallLocation").ToString();
}
}
catch { }
}
return "";
}
RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");
string location = FindByDisplayName(regKey, "MSN");
MessageBox.Show(location);Kodlar alıntıdır.
Mantığına gelirsek,Windows ta yüklü programların listesi HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall anahtarından elde edilebilir.
sssa
- Düzenleyen Semih ARTAN 10 Nisan 2017 Pazartesi 16:07
- Yanıt Olarak İşaretleyen umut Çelik 11 Nisan 2017 Salı 12:19
-
protected SortedDictionary<string, string> programlar = null;
public SortedDictionary<string, string> Programlar
{
get
{
if (programlar == null)
{
programlar = new SortedDictionary<string, string>();
using (RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"))
{
foreach (string subKeyName in regKey.GetSubKeyNames())
{
using (RegistryKey subKey = regKey.OpenSubKey(subKeyName))
{
try
{
if (subKey.GetValue("DisplayName") != null && subKey.GetValue("InstallLocation") != null)
programlar.Add(subKey.GetValue("DisplayName").ToString(), subKey.GetValue("InstallLocation").ToString());
}
catch
{
}
}
}
}
}
return programlar;
}
}private void Form1_Load(object sender, EventArgs e)
{comboBox1.DataSource = new BindingSource(Programlar, null);
comboBox1.DisplayMember = "Key";
comboBox1.ValueMember = "Value";
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
label1.Text = comboBox1.SelectedValue;
}- Düzenleyen MuratAKSARAY 11 Nisan 2017 Salı 07:29
- Yanıt Olarak İşaretleyen umut Çelik 11 Nisan 2017 Salı 12:20
-