标题:求助大牛,该代码用c#写后无法运行
只看楼主
gold5115
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-3-11
 问题点数:0 回复次数:1 
求助大牛,该代码用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
xydddaxia
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:33
帖 子:466
专家分:2307
注 册:2009-3-20
得分:0 
发图,贴代码,详细说明问题

站在春哥的肩膀上
2012-03-19 11:30



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-362807-1-1.html




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

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