Пример #1
0
        private static bool VerifyMachineCode(string keypath)
        {
            bool VerifySign = false;

            try
            {
                using (StreamReader objInput = new StreamReader(Path.Combine(keypath, ""), System.Text.Encoding.UTF8))
                {
                    string[] strContents = objInput.ReadToEnd().Trim().TrimEnd('&').Split('&');

                    string deviceInfo = DeviceInfo.Instance().CpuID + DeviceInfo.Instance().MacAddress + DeviceInfo.Instance().DiskID + DeviceInfo.Instance().SystemType;

                    string curMachineCode = CodeRegister.GetMd5("南京奥拓电子" + deviceInfo);

                    foreach (string var in strContents)
                    {
                        string contents = CodeRegister.Decrypt("aoto0587", var);

                        contents = contents.Substring(contents.IndexOf("_") + 1, contents.Length - contents.IndexOf("_") - 1);
                        if (contents.Contains(curMachineCode))
                        {
                            if (DateTime.Compare(DateTime.Now, DateTime.Parse(contents.Replace(curMachineCode + "_", ""))) < 0)
                            {
                                if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), @"TempPPF\protectppf.dat")))
                                {
                                    File.Delete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), @"TempPPF\protectppf.dat"));
                                }
                                using (Stream strSall = new FileStream(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), @"TempPPF\protectppf.dat"), FileMode.Create, FileAccess.Write))
                                {
                                    using (StreamWriter strWirtSall = new StreamWriter(strSall, UTF8Encoding.UTF8))
                                    {
                                        strWirtSall.Write(var);
                                    }
                                }

                                VerifySign = true;
                                break;
                            }
                        }
                    }
                }
            }
            catch
            {
                //不记录日志
                VerifySign = false;
            }

            return(VerifySign);
        }
Пример #2
0
        private static bool VerifyMachineCode(ref string stateCode)
        {
            bool VerifySign = false;

            try
            {
                if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), @"TempPPF\protectppf.dat")))
                {
                    return(VerifySign);
                }
                using (StreamReader objInput = new StreamReader(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), @"TempPPF\protectppf.dat"), System.Text.Encoding.UTF8))
                {
                    string contents = CodeRegister.Decrypt("aoto0587", objInput.ReadToEnd().Trim());

                    contents = contents.Substring(contents.IndexOf("_") + 1, contents.Length - contents.IndexOf("_") - 1);

                    //string[] split = System.Text.RegularExpressions.Regex.Split(contents, "&", RegexOptions.None);

                    string curMachineCode = CodeRegister.GetMd5("南京奥拓电子" + DeviceInfo.Instance().CpuID + DeviceInfo.Instance().MacAddress + DeviceInfo.Instance().DiskID + DeviceInfo.Instance().SystemType);

                    if (contents.Contains(curMachineCode))
                    {
                        if (DateTime.Compare(DateTime.Now, DateTime.Parse(contents.Replace(curMachineCode + "_", ""))) < 0)
                        {
                            VerifySign = true;
                            stateCode  = "激活成功";
                        }
                    }
                }
            }
            catch
            {
                //不记录日志
                VerifySign = false;
            }
            finally
            {
                if (!VerifySign)
                {
                    stateCode = "激活失败";
                    File.Delete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), @"TempPPF\protectppf.dat"));
                }
            }
            return(VerifySign);
        }