static void Main(string[] args) { var options = new Options(); if (Parser.Default.ParseArguments(args, options)) { if (File.Exists(options.InputFilePath)) { PDIWTEncrypt pdiwt = new PDIWTEncrypt(); StringBuilder outputsb = new StringBuilder(); using (StreamReader sr = new StreamReader(options.InputFilePath)) { string line; while ((line = sr.ReadLine()) != null) { outputsb.AppendLine(line + " ==> " + pdiwt.GenerateActivationCodeString(line)); } } File.WriteAllText(options.OutputFilePath, outputsb.ToString()); Console.WriteLine($"输入文件{Path.GetFileName(options.InputFilePath)}处理完成!"); } else { Console.WriteLine($"=>不存在{options.InputFilePath}"); } } }
public static void VerifyActivationState(Action action) { var pdiwtkey = Registry.CurrentUser.OpenSubKey(@"Bentley\MicroStation\PDIWTMSADDIN"); string activationprogrampath = pdiwtkey?.GetValue("ActivateProgramPath") as string; if (string.IsNullOrEmpty(activationprogrampath)) { MessageBox.Show("未找到激活程序,安装过程中出现错误,请卸载后重新安装!", "激活错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } PDIWTEncrypt _pdiwt = new PDIWTEncrypt(); if (RegistryUtilities.GetActivationKeyFromRegistry() != _pdiwt.GenerateActivationCodeString()) { Process.Start(activationprogrampath); } else { action(); } }