| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 604 人关注过本帖
标题:求助大牛,该代码用c#写后无法运行
取消只看楼主 加入收藏
gold5115
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-3-11
收藏
 问题点数:0 回复次数:0 
求助大牛,该代码用c#写后无法运行
  

注册码生成代码如下



 m_machineCode= GetMachineCode("RDH");

相关函数为

        public string GetMachineCode(string seriesNum)
        {
            string s = this.GetDeviceID() + seriesNum;
            MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider();
            string src = BitConverter.ToString((Encoding.Default.GetBytes(s))).Replace("-", "");
            return this.GetCode(src, 3);
        }

 

      public string GetDeviceID()
        {
            byte[] outputBuffer = new byte[0x100];
            int length = outputBuffer.Length;
            int bytesReturned = 0;
            if (!KernelIoControl(IOCTL_HAL_GET_DEVICEID, IntPtr.Zero, 0, outputBuffer, length, ref bytesReturned))
            {
                return null;
            }
            int startIndex = BitConverter.ToInt32(outputBuffer, 4);
            int num4 = BitConverter.ToInt32(outputBuffer, 12);
            int num5 = BitConverter.ToInt32(outputBuffer, 0x10);
            StringBuilder builder = new StringBuilder();
            builder.Append(string.Format("{0:X8}-{1:X4}-{2:X4}-{3:X4}-", new object[] { BitConverter.ToInt32(outputBuffer, startIndex), BitConverter.ToInt16(outputBuffer, startIndex + 4), BitConverter.ToInt16(outputBuffer, startIndex + 6), BitConverter.ToInt16(outputBuffer, startIndex + 8) }));
            for (int i = num4; i < (num4 + num5); i++)
            {
                builder.Append(string.Format("{0:X2}", outputBuffer[i]));
            }
            return builder.ToString();
        }

编码生成函数为

    GetRegHead2(m_machineCode);

        public string GetRegHead2(string machineCode)
        {
            string s = machineCode;
            MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider();
            string src = BitConverter.ToString((Encoding.Default.GetBytes(s))).Replace("-", "");
            return this.GetCode(src, 2);
        }

搜索更多相关主题的帖子: 函数 public return 注册码 
2012-03-11 10:15
快速回复:求助大牛,该代码用c#写后无法运行
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025694 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved