我最近也在开发一个项目,也是用C#调用C语言的DLL方法,下面是我的总结,我也不太懂,希望能帮到你:在C#中调用C语言方法(dll文件),首先要将封装好的DLL文件导入本项目的bin目录下的Debug文件夹里,然后再在要使用的页面定义DLL函数接口
 [DllImport("CDLL2", EntryPoint = "CheckLogin", CallingConvention = CallingConvention.StdCall)]
 public static extern string CheckLogin(string UserName, string PassWord);  //此为DLL文件里的方法原型,在此调用
若dll里的方法的返回值是xml,则还需要对其进行解析,取值,解码:
 public static bool getResult(string s)    //取出xml中result节点的值
        {
            xmldoc = new XmlDocument();
            xmldoc.LoadXml(s);
            string result;
            try
            {
                result = xmldoc.GetElementsByTagName("result")[0].ChildNodes[0].Value;
               // MessageBox.Show(result);
                if (result.Equals("True"))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);     
        
            }
            return false;
对取出的节点的值进行解码(从C语言到c#的转换):Encoding.Default.GetString(Convert.FromBase64String(result));
将编码的字节数组转换为已解码的字符串
System.Web.HttpUtility.UrlDecode(strContent, System.Text.Encoding.GetEncoding("GB2312")).ToUpper();