using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Runtime.InteropServices;
namespace WindowsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }       
        //宏定义
        private long contryCode = 5;//国家code
        private long contryName = 4098;//国家名称        [DllImport("Kernel32.dll")]
        private static extern long GetLocaleInfo(long inLocal, long lcType, String lpLcData, long cchData);
               private void button1_Click(object sender, EventArgs e)
        {
            String strContryCode = "";            for (long i = 0; i < 65535; i++)
            {
                strContryCode = this.getLinfo(i,contryCode);
                if (strContryCode.Length != 0)
                {
                    this.comboBoxContryCode.Items.Add(strContryCode);
                }                strContryCode = this.getLinfo(i, contryName);
                if (strContryCode.Length != 0)
                {
                    this.comboBoxContryCode.Items.Add(strContryCode);
                }
            }
        }        private String getLinfo(long local, long intType)
        {
            //初始值300个空格(好像C#里面没有space这个函数)
            String newString = "                                                                                                                                                                                                                                                                                                            ";            long longLength = GetLocaleInfo(local, intType, newString, (long)newString.Length);            if (longLength < 0)
            {
                return String.Empty;
            }            //返回国家名和对应的code
            return newString;
        }
    }
}
这是我写的一部分代码,怎么运行也不对,好像引进的那个dll没有派上用场,请明白的人帮我看看,我的要求是取得国家名称和所对应的code值,谢谢。在线等待。

解决方案 »

  1.   

    你的问题提的太笼统了。“取得国家名称和所对应的code值”,你是要从哪里取这些值?请来龙去脉讲明。
    用哈希表(Hashtable是System.Collections命名空间提供的一个容器,用于处理和表现类似key/value的键值对)不知能否实现你所说的功能。
      

  2.   

    谢谢支持,我是要从系统中获取国家名称和他们所对应的code值,
    例如Chinese(PRC) -〉2052 依此类推如果是English -> ????
    在NT下可能会返回137条记录,而在ME下可能返回148条记录,我现在就想取得这些东西,请问怎么取?请给给出详细代码,谢谢。