You must Sign In to post a response.
  • Category: .NET

    Want to access control panel through code in c#

    Hi,


    I want to check what ever setting are there in region and language in control panel through code in C#
    . Kindly Reply
  • #764610
    using System.Globalization;
    using System.Threading;
    DateTime dt = DateTime.Now;
    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");//Set CurrentCulture to english U.S
    Console.WriteLine(dt.ToString("d"));//Get date

    Or you can modify registry entries as follows:
    using Microsoft.Win32;
    RegistryKey objRegKey = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true);
    string[] szLang = { "en-ZA" };
    objRegKey.SetValue("PreferredUILanguagesPending", szLang, RegistryValueKind.MultiString);//REG_MULTI_SZ
    Please go through this article for more details: http://www.codeproject.com/Articles/2422/Working-with-Registry-in-NET
    Hope it helps.
    Regards,
    Shashikant Gurav
    shashikantgurav22@gmail.com

  • #764618
    To get default regional and language setting, you need to hit to control panel, Just use System.globalization namespace, it will return the system settings.
    see below snippet
    using System;
    using System.Globalization;

    public class Example
    {
    public static void Main()
    {
    CultureInfo culture = CultureInfo.CurrentUICulture;
    Console.WriteLine("The current UI culture is {0} [{1}]",
    culture.NativeName, culture.Name);
    }
    }
    // The example displays output like the following:
    // The current UI culture is English (United States) [en-US]

    in above code you will all information about current CurrentCulture. you can set new culture using code also.

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #764657
    Hi,

    You may use CultureInfo object to accomplish this task.

    Below is the sample code which may help you,

    http://dotnetcodr.com/2014/08/15/finding-the-users-current-region-using-regioninfo-in-net-c/


    Regards,
    Asheej T K
    Microsoft MVP[ASP.NET/IIS]
    DotNetSpider MVM


Sign In to post your comments