问题描述
我正在将例程从VB6(一种我不知道的语言)转换为C#.在VB6代码中具有. . .
I'm converting a routine from VB6 (a language I do not know) to C#. In the VB6 code it has . . .
LCID = GetThreadLocale
rc = GetLocaleInfo(LCID, LOCALE_SDECIMAL, data, dataLen)
所以在我的C#中,我在类主体中添加了
So in my C#, in the class body, I've added
[DllImport("kernel32.dll", SetLastError = true)]
static extern int GetThreadLocale();
. . .这似乎使我可以拨打第一个电话.
. . . which seems to allow me to make the first call.
但是在谷歌搜索 GetLocaleInfo()中,我看到了冲突的信息.在网络上,除了普通的香草 GetLocaleInfo()外,还有:
But in Googling GetLocaleInfo() I see conflicting information. On the web, in addition to the plain, vanilla GetLocaleInfo(), there's also :
在 http://www.webtropy.com/articles/art9-1.asp?f = GetLocaleInfo 指的是称为 GetLocaleInfA()的东西.
在这个StackOverflow问题中 Windows:是否从语言环境字符串中获取LCID?提到了 GetLocaleInfoEx().
And in this StackOverflow question Windows: Get LCID from locale string? there's a mention of a GetLocaleInfoEx().
我如何知道要使用哪一个?如何设置它才能被调用? (顺便说一句,我还需要对 SetLocaleInfo()做同样的事情.
How do I know which one to use, and how do I set it up to be called? (BTW, I'll also need to do the same thing for SetLocaleInfo() .
推荐答案
使用正确的.NET Framework方法:
Use the proper .NET Framework method:
http: //msdn.microsoft.com/zh-CN/library/system.globalization.cultureinfo.lcid(v=vs.110).aspx
Thread.CurrentThread.CurrentCulture.CultureInfo.LCID;
Thread.CurrentThread.CurrentCulture.CultureInfo.LCID;
这篇关于如何从C#访问GetLocaleInfo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!