Reputation: 5003
Is it possible to find user's culture if I cannot use Thread.CurrentCulture nor (naturally) CultureInfo.CurrentCulture?
I cannot use them because I'm just modifying small part of the huge project, and Thread.CurrentCulture
is set to different culture somewhere in it.
One possible solution is to remember original culture when Thread.CurrentCulture
is being set. But it there a way to get proper user's culture no matter what?
Upvotes: 2
Views: 301
Reputation: 262919
You can p/invoke GetUserDefaultLCID() and pass the resulting value to the CultureInfo constructor that takes an int
:
[DllImport("kernel32.dll")]
static extern int GetUserDefaultLCID();
CultureInfo defaultUserCulture = new CultureInfo(GetUserDefaultLCID());
Upvotes: 3