Friday 28 June 2013

Visual Studio 2008 - Toolbar missing 'Release' / 'Debug' dropdown build configuration

It describes how to get this useful dropdown visible:
  1. In Visual Studio 2008, click “Tools” -> “Options”

  1. Under “Projects and Solutions” -> “General”, check “Show advanced build options”, and click “OK”
 
          2.Right click anywhere in the blank space of the toolbar and click “Customize…”

      
       3.In “Commands” tab, select “Build” in “Categories”.

4. Scroll the right listbox to the bottom and drag “Solution Configurations” to the toolbar

Tuesday 4 June 2013

C# - Equivalent to the function GetSetting() in VB .NET

Getsetting DLL Download

using Microsoft.Win32;


public static string GetSetting(string applicationName, string sectionName, string key, string valeurParDéfaut)
        {
            StringBuilder path;
            RegistryKey registryKey;

            path = new StringBuilder(@"Software\VB and VBA Program Settings");

            // Generate the path of the key
            if (string.IsNullOrEmpty(applicationName) == false)
            {
                path.Append('\\');
                path.Append(applicationName);

                if (string.IsNullOrEmpty(sectionName) == false)
                {
                    path.Append('\\');
                    path.Append(sectionName);
                }
            }
            // Open key
            registryKey = Registry.CurrentUser.OpenSubKey(path.ToString());


            // If the key does not exist, return the default Open key
            if (registryKey == null)
            {
                return valeurParDéfaut;
            }
            try
            {
                //Read the value contained in the key
                return (string)registryKey.GetValue(key, valeurParDéfaut);
            }
            finally
            {
                //registryKey.Dispose();
            }
        }

public static string GetSetting(string applicationName, string sectionName, string key)
        {
            return GetSetting(applicationName, sectionName, key, null);
        }


//It is now possible to use this class like this:
string s;
            s= Getsetting.Form1.GetSetting("JRFleetini", "DatabasePathini", "dbPathini", null);
            MessageBox.Show(s);