473,395 Members | 1,670 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

GetLocaleInfo

I'm trying to call the Windows API's function
GetLocaleInfo but the call fails. Using the GetLastError
function, I get error 126: The specified module could not
be found. Here's my code:

private const int LOCALE_SYSTEM_DEFAULT=0x400;
private const int LOCALE_SDECIMAL=0xE;

[DllImport("kernel32.dll",SetLastError=true)]
private static extern int GetLocaleInfoA(int Locale,int
LCType,string lpLCData,int cchData);

private const Int32 MAX_SYMBOL_LENGTH=4;

Int32 callResult;
String symbol;

symbol=new String(' ',MAX_SYMBOL_LENGTH+1);
callResult=GetLocaleInfoA
(LOCALE_SYSTEM_DEFAULT,LOCALE_SDECIMAL,symbol,symb ol.Length
);

Nov 16 '05 #1
1 11318
Beholder wrote:
I'm trying to call the Windows API's function
GetLocaleInfo but the call fails. Using the GetLastError
function, I get error 126: The specified module could not
be found. Here's my code:

private const int LOCALE_SYSTEM_DEFAULT=0x400;
private const int LOCALE_SDECIMAL=0xE;

[DllImport("kernel32.dll",SetLastError=true)]
private static extern int GetLocaleInfoA(int Locale,int
LCType,string lpLCData,int cchData);

private const Int32 MAX_SYMBOL_LENGTH=4;

Int32 callResult;
String symbol;

symbol=new String(' ',MAX_SYMBOL_LENGTH+1);
callResult=GetLocaleInfoA
(LOCALE_SYSTEM_DEFAULT,LOCALE_SDECIMAL,symbol,symb ol.Length
);


Hi Beholder,

this one worked for me:

[DllImport("kernel32.dll")]
static extern int GetLocaleInfo(uint Locale, uint LCType,
[Out] System.Text.StringBuilder lpLCData, int cchData);

private const uint LOCALE_SYSTEM_DEFAULT=0x400;
private const uint LOCALE_SDECIMAL=0xE;

private string GetInfo(uint lInfo)
{
System.Text.StringBuilder lpLCData = new System.Text.StringBuilder(256);
int ret = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, lInfo, lpLCData,
lpLCData.Capacity);

if (ret > 0)
{
return lpLCData.ToString().Substring(0, ret -1);
}
return string.Empty;
}

//usage:
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show(GetInfo(LOCALE_SDECIMAL));
}

Cheers

Arne Janning
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Onega | last post by:
Hi I create a simple win32 project (VC2003, windows2003(English) , and do simple paint in WM_PAINT message, when the project use multi-character set, it is OK. but when I change to UNICODE,...
9
by: WizardLee | last post by:
Hi, all, A new feature is required to add to my program today. But I do not have any idea about it. The feature should implement these two functions: 1, Select "Install files for East Asia...
2
by: Li Pang | last post by:
User can changes his/her local date setting, i.e., "M/d/yyyy", "dd/MMM/yyyy", .... etc. which interprets the date (string type) in the different way. for example "02/05/2004" can be the second of May...
6
by: **Developer** | last post by:
Notice below I sometimes used the "A" version. I found by cut-and-try that only the "A" version would work correctly. Anyone have a suggestion of why the "W" version would not work correctly? ...
2
by: Simos_V | last post by:
The following code is converted from VB6 to VS2005. The call to GetLocaleInfoLS returns always 0. Please HELP !!!! <StructLayout(LayoutKind.Sequential)> _ Private Structure LOCALESIGNATURE...
37
by: Zhiv Kurilka | last post by:
Hi, I have a text file with following content: "((^)|(.* +))§§§§§§§§" if I read it with: k=System.IO.StreamReader( "file.txt",System.Text.Encoding.ASCII); k.readtotheend()
18
by: Boris Yeltsin | last post by:
OK, I have a database table, it has prices of products in it, like so: ProductPrice MONEY ProductIsoCurrencyCode CHAR(3) Now, both CultureInfo and RegionInfo have...
4
by: George | last post by:
Hi, I am puzzled by the following and seeking some assistance to help me understand what happened. I have very limited encoding knowledge. Our SAP system writes out a text file which includes...
4
by: Chris | last post by:
I tried to retrieve the digit grouping symbol in MSAccess but unfortunately 3;0 is retrieved instead of comma which is my symbol. Function retrieves decimal symbol and list separator without any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.