Click here to Skip to main content
15,924,196 members
Home / Discussions / C#
   

C#

 
AnswerRe: How do I change the connection string for Database Designer-designed objects? Pin
PIEBALDconsult14-Sep-11 15:11
mvePIEBALDconsult14-Sep-11 15:11 
QuestionAxWindowsMediaPlayer Pin
Francesco-8014-Sep-11 7:08
Francesco-8014-Sep-11 7:08 
AnswerRe: AxWindowsMediaPlayer Pin
Francesco-8015-Sep-11 1:18
Francesco-8015-Sep-11 1:18 
Questionwhat is the "game engine"???? Pin
gif202013-Sep-11 23:40
gif202013-Sep-11 23:40 
AnswerRe: what is the "game engine"???? Pin
Pete O'Hanlon13-Sep-11 23:52
mvePete O'Hanlon13-Sep-11 23:52 
GeneralRe: what is the "game engine"???? Pin
OriginalGriff14-Sep-11 3:10
mveOriginalGriff14-Sep-11 3:10 
GeneralRe: what is the "game engine"???? Pin
molesworth14-Sep-11 7:27
molesworth14-Sep-11 7:27 
QuestionGetThreadPreferredUILanguages Pin
marca29213-Sep-11 22:56
marca29213-Sep-11 22:56 
Hi,

I need to get all installed languages on the computer. "Control Panel / Regional and Language / Keyboards and Languages / Display language". How can I get the selected language in .NET?

Our application has language settings for a lot of different languages. If our application don't has support for the selected language in "Display language" then we have to see if we has support for a fallback language.

I tried to use "GetThreadPreferredUILanguages" call and it work fine when I use C++, but I can't get is working on .NET. Is there an .NET call I can use instead to get selected languages and also the fallback languages?

C++ code
C++
wchar_t buf[2323];

wchar_t *pBuf;

ULONG numLangs;

ULONG size= 2323;



GetThreadPreferredUILanguages(MUI_MERGE_USER_FALLBACK, &numLangs, buf, &



C# code
C#
[DllImport("Kernel32.dll", CharSet = CharSet.Auto)]

       static extern System.Boolean GetThreadPreferredUILanguages(

           System.UInt32 dwFlags,

           ref System.UInt32 pulNumLanguages,

           out System.IntPtr pwszLanguagesBuffer,

           ref System.UInt32 pcchLanguagesBuffer

           );





         uint MUI_MERGE_USER_FALLBACK = 0x20;

           uint numLang = 0;

           IntPtr pwszLangBuf = new IntPtr();

           uint langBuf = 2323;

           bool b = GetThreadPreferredUILanguages(MUI_MERGE_USER_FALLBACK, ref numLang, out pwszLangBuf, ref langBuf);



           string tmp = Marshal.PtrToStringAuto(pwszLangBuf


tmp string variable contains only a lot of chinese characters after Marshal.PtrToStringAuto(pwszLangBuf);.

pulNumLanguages and pcchLanguagesBuffer returns the same in both C++ and C#.

See more information about GetThreadPreferredUILanguages on
http://msdn.microsoft.com/en-us/library/dd318128(v=vs.85).aspx[^]


What is wrong?

Regards
Olof
AnswerRe: GetThreadPreferredUILanguages Pin
Luc Pattyn14-Sep-11 1:52
sitebuilderLuc Pattyn14-Sep-11 1:52 
AnswerRe: GetThreadPreferredUILanguages Pin
BobJanova14-Sep-11 2:14
BobJanova14-Sep-11 2:14 
QuestionWhere to use Try/Catch block? [modified] Pin
Adam_Dev13-Sep-11 22:21
Adam_Dev13-Sep-11 22:21 
AnswerRe: Where to use Try/Catch block? Pin
BobJanova13-Sep-11 22:40
BobJanova13-Sep-11 22:40 
GeneralRe: Where to use Try/Catch block? [modified] Pin
Adam_Dev13-Sep-11 23:01
Adam_Dev13-Sep-11 23:01 
GeneralRe: Where to use Try/Catch block? Pin
BobJanova14-Sep-11 2:09
BobJanova14-Sep-11 2:09 
AnswerRe: Where to use Try/Catch block? Pin
Pete O'Hanlon13-Sep-11 22:57
mvePete O'Hanlon13-Sep-11 22:57 
GeneralRe: Where to use Try/Catch block? [modified] Pin
Adam_Dev13-Sep-11 23:10
Adam_Dev13-Sep-11 23:10 
GeneralRe: Where to use Try/Catch block? Pin
Pete O'Hanlon13-Sep-11 23:50
mvePete O'Hanlon13-Sep-11 23:50 
GeneralRe: Where to use Try/Catch block? Pin
Adam_Dev14-Sep-11 0:26
Adam_Dev14-Sep-11 0:26 
AnswerRe: Where to use Try/Catch block? Pin
Luc Pattyn14-Sep-11 2:11
sitebuilderLuc Pattyn14-Sep-11 2:11 
GeneralRe: Where to use Try/Catch block? Pin
BobJanova14-Sep-11 2:22
BobJanova14-Sep-11 2:22 
GeneralRe: Where to use Try/Catch block? Pin
Adam_Dev14-Sep-11 2:33
Adam_Dev14-Sep-11 2:33 
AnswerRe: Where to use Try/Catch block? Pin
Luc Pattyn14-Sep-11 2:51
sitebuilderLuc Pattyn14-Sep-11 2:51 
JokeArrayList Pin
Subodh Kumar Jain13-Sep-11 20:38
Subodh Kumar Jain13-Sep-11 20:38 
GeneralRe: ArrayList Pin
Wayne Gaylard13-Sep-11 21:04
professionalWayne Gaylard13-Sep-11 21:04 
GeneralRe: ArrayList Pin
PIEBALDconsult14-Sep-11 2:27
mvePIEBALDconsult14-Sep-11 2:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.