Se afișează postările cu eticheta windows registry. Afișați toate postările
Se afișează postările cu eticheta windows registry. Afișați toate postările

duminică, 16 ianuarie 2011

Finding the path to an installed application in C#

Well, you can find the path to a locally installed application by querying the windows registry.
The information is here:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\

Example photoshop.exe

I wrote this function in C# to do this for me:




///
/// get the path to a specific application from the registry
///

/// name of the application exe
///
public static string GetApplicationPath(string ExeName)
{
try
{
RegistryKey OurKey = Registry.LocalMachine;
OurKey = OurKey.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\App Paths\"+ExeName, true);
if (OurKey != null)
return OurKey.GetValue("").ToString();
else
return "";
}
catch(Exception ex)
{
return "";
}
}

The Trie: A Neglected Data Structure

From the very first days in our lives as  programmers , we’ve all dealt with data structures: Arrays, linked lists, trees, sets, stacks and...