Skip to main content

Discover Click Once Applications Currently Installed

To discover “Click Once” applications currently installed in a machine, below code helps to find out currently installed click once applications.
The GetInstalledClickOnceApps() method read the installed click once applications from Registry;add it to the list and return the list.
The LoadInstalledClickOnceApps() method binds installed application names and version to the list view.
The Load() method is the root method.


Code:
public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            Load();
        }


        ///
        /// Load
        ///

        private void Load()
        {
            try
            {
                LoadInstalledClickOnceApps();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Not able to load the installed click once applications!");
            }
        }


        ///
        /// Bind installed application names to the VIEW
        ///

        private void LoadInstalledClickOnceApps()
        {
            IDictionary iClickOnceApps = GetInstalledClickOnceApps();
            foreach (KeyValuePair keyValuePair in iClickOnceApps)
            {
                listAppView.Items.Add(new ListViewItem(new[] { keyValuePair.Value, keyValuePair.Key }));
            }
        }

        ///

        /// Read the installed click once applications from Registry;add it to the list and return the list
        ///
        ///
        private IDictionary GetInstalledClickOnceApps()
        {
            IDictionary installedApps = new Dictionary();
            RegistryKey registryKeys = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall");
            string[] appKeyNames = registryKeys.GetSubKeyNames();
            string displayName = null;
            string displayVersion = null;
            foreach (string appKeyName in appKeyNames)
            {
                RegistryKey appKey = registryKeys.OpenSubKey(appKeyName);
                displayName = (string)appKey.GetValue("DisplayName");
                displayVersion = (string)appKey.GetValue("DisplayVersion");
                installedApps.Add(displayVersion, displayName);
                appKey.Close();
            }
            registryKeys.Close();
            return installedApps;
        }
    }

Popular posts from this blog

WCF Service Exception PlainXmlWriter+MaxSizeExceededException

For a WCF service the exception 'System.ServiceModel.Diagnostics.PlainXmlWriter+MaxSizeExceededException' generally occurs when we switched on logging and tracing.   A message was not logged. Exception: System.InvalidOperationException: There was an error generating the XML document. ---> System.ServiceModel.Diagnostics.PlainXmlWriter+MaxSizeExceededException: Exception of type 'System.ServiceModel.Diagnostics.PlainXmlWriter+MaxSizeExceededException' was thrown.   The reason is that "maxSizeOfMessageToLog" configuration parameter value is set to a value lower than the size of the message to log. < system.serviceModel>   < diagnostics > <!-- log all messages received or sent at the transport or service model levels --> < messageLogging logEntireMessage = " true " logMessagesAtServiceLevel = " true " logMalformedMessages = " true " logMessagesAtTransportLevel = " true "    maxMessa...

ISAPI & CGI Restriction configuration missing in IIS

In windows 7 by default ISAPI & CGI Restrictions are not configured. To enable ISAPI & CGI restrictions, GoTo -> Control Panel -> Programs -> Click on "Windows features on or off -> Expand Internet Information Services - >Expand World Wide Web Services ->Select CGI and ISAPI extensions and Click OK. After enabling, Check in IIS, Open your IIS and the feature will be available. What is ISAPI and CGI restrictions : ISAPI and CGI restrictions are request handlers that allow dynamic content to execute on a server. These restrictions are either CGI files (.exe) or ISAPI extensions (.dll). You can add custom ISAPI or CGI restrictions if the IIS configuration system allows this.

Implementing Parallelism With A SearchResultCollection

Implementing Parallel.ForEach with a SearchResultCollection: The below piece of code helps to check the given user is a part of the given active directory group. To implement Parallel.ForEach with a SearchResultCollection, do the casting with the SearchResult object and covert it into a list. //// Directory Searcher var directorySearcher = new DirectorySearcher(string.Format("(CN={0})", groupName)); //// Find group var searchResultCollection = directorySearcher.FindAll().Cast ().ToList(); Parallel.ForEach(searchResultCollection, searchResult => {  // enumerate members  var resultPropColl = searchResult.Properties;  Parallel.ForEach(resultPropColl["member"].Cast ().ToList(), member =>  {    var memberEntry = new DirectoryEntry("LDAP://" + member);    var userProperties = memberEntry.Properties;    if (GetUserNameFromProperties(userProperties, "sAMAccountName") == userName)    {      return true; ...