CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14
  1. #1
    Join Date
    Jan 2000
    Location
    CA, USA
    Posts
    305

    (Urgent:) Change system locale programatically

    Hi,
    I have a requirement to change the system locale using Win32 API. There is a call GetSystemDefaultLCID but nothing like SetSystemDefaultLCID to set the default locale. Such a method is available in coredll.dll but looks like it's not free. Is that right?
    Any information on this or any workaround with a sample code would be greatly appreciated!

    Thanks,
    Kannan

  2. #2
    Join Date
    Jan 2000
    Location
    CA, USA
    Posts
    305

    Change system locale programatically

    Hi,
    I have a requirement to change the system locale using Win32 API or MFC. There is a call GetSystemDefaultLCID but nothing like SetSystemDefaultLCID to set the default locale. Such a method is available in coredll.dll but looks like it's not free. Is that right?
    Any information on this or any workaround with a sample code would be greatly appreciated!

    Thanks,
    Kannan

  3. #3
    Join Date
    Jan 2000
    Location
    CA, USA
    Posts
    305

    (Urgent:)Change system locale programatically

    Hi,
    I have a requirement to change the system locale using Win32 API. There is a call GetSystemDefaultLCID but nothing like SetSystemDefaultLCID to set the default locale. Such a method is available in coredll.dll but looks like it's not free. Is that right?
    Any information on this or any workaround with a sample code would be greatly appreciated!

    Thanks,
    Kannan

  4. #4
    Join Date
    Feb 2003
    Location
    California
    Posts
    334

    Re: (Urgent:) Change system locale programatically

    Take a look at SetLocaleInfo()
    Henri Hein
    Principal Engineer, Propel
    Do not credit Propel with my views or opinions.

  5. #5
    Join Date
    Jan 2000
    Location
    CA, USA
    Posts
    305

    Re: (Urgent:) Change system locale programatically

    Hi,
    Thanks for the response.
    SetLocaleInfo impacts only at the user's session not at system level.

    Thanks,
    Kannan

  6. #6
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Change system locale programatically

    Quote Originally Posted by kannanbalu
    I have a requirement to change the system locale using Win32 API or MFC. There is a call GetSystemDefaultLCID but nothing like SetSystemDefaultLCID to set the default locale.
    The system locale is a setting made by the user (or the administrator) of an installation - applications should take it into consideration, but not change it. What's the reason for the requirement to change the locale? I'd question that in the first place. In any case, you can change individual parts of the locale info for your own process via SetLocaleInfo(), if that's what you need.

  7. #7
    Join Date
    Jan 2000
    Location
    CA, USA
    Posts
    305

    Re: Change system locale programatically

    Hi,
    Thanks for the response. I've a requirement where I need to run some of my testcases on different locales automatically. I was under the impression that anything was possible with Win32 API/MFC. SetLocaleInfo is only at the user session. I'm looking for changing the system default itself.
    One dirty workaround could be to send messages to the Regional Options (in Control Panel) and do all the operations that we normally do manually to change the system default. But I'm sure there must be a better way of handling it.

    I know coredll.dll has a method for doing this but I guess it's not free

    Thanks,
    Kannan

  8. #8
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Change system locale programatically

    Quote Originally Posted by kannanbalu
    I know coredll.dll has a method for doing this but I guess it's not free
    What do you mean by "it's not free" - that you have to pay for calling it? Seriously, if the DLL has that function, and you know it, than it might be at worst undocumented, but you can call it. You just need to figure out the correct calling parameters and return value, but in the case of SetSystemDefaultLCID that should be easy. And if it's just for a test case used during development, there's nothing too bad about using undocumented API functions. I just don't understand what you are referring to when you say "coredll.dll" - AFAIK, it's non of the Win32 system DLLs.

  9. #9
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588

    Re: (Urgent:)Change system locale programatically

    You basically can't change it, unless you reinstall Windows. There is a program from Microsoft which lets you run individual programs with a "different system locale", but all that this does is that it intercepts API calls and returns the locale you specified.

    Why do you want/need to do this anyways?

    [P.S. Moved to the Win32 forum, which is more appropriate]
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

  10. #10
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588

    Re: Change system locale programatically

    [ Oh and don't cross-post, that just leaves people with no idea what others have answered. Just choose the most appropriate forum from the start ]

    [ Merged threads ]
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

  11. #11
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588

    Re: Change system locale programatically

    Just found the link back from that MS tool. It's called AppLocale and you can find it on their Globaldev site.
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

  12. #12
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    Re: Change system locale programatically

    Quote Originally Posted by gstercken
    I just don't understand what you are referring to when you say "coredll.dll" - AFAIK, it's non of the Win32 system DLLs.
    Windows CE....I thunk...

  13. #13
    Join Date
    Jan 2000
    Location
    CA, USA
    Posts
    305

    Re: Change system locale programatically

    Hi all,
    Thanks for all the responses.

    > I just don't understand what you are referring to when you say "coredll.dll" - AFAIK, it's non of the Win32 system DLLs.

    You're right. coredll.dll is not a win32 system dll. I found it on the web and as I said you need to pay for it.

    The AppLocale seems to be interesting. I'll try it out.


    Thanks,
    Kannan

  14. #14
    Join Date
    Apr 2008
    Posts
    8

    Re: Change system locale programatically


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured