예제 #1
0
        static void Pack(string[] args, string outputFile)
        {
            PackagingInfo p           = new PackagingInfo();
            string        addFile     = CommandLineParser.GetArgumentValue(args, "addfile", "");
            string        addFileName = Path.GetFileName(addFile);

            p.Files = new List <AddFileInfo>();
            p.Files.Add(new AddFileInfo(addFile, "%Root Folder%\\" + addFileName));
            p.Operations = new List <ExecuteOperationInfo>();
            for (int i = 0; i < 10; i++)
            {
                string opeFile = CommandLineParser.GetArgumentValue(args, "opefile" + (i + 1), null);
                string opeArg  = CommandLineParser.GetArgumentValue(args, "opearg" + (i + 1), "");
                if (opeFile == null)
                {
                    break;
                }
                p.Operations.Add(new ExecuteOperationInfo(opeFile, opeArg));
            }
            p.Option = new OptionInfo();
            p.Option.IsCompressFile      = CommandLineParser.GetArgumentValue(args, "compress", "true").ToLower() == "true";
            p.Option.IsCreateRandomBytes =
                CommandLineParser.GetArgumentValue(args, "genrandombytes", "true").ToLower() == "true";
            p.Option.RandomBytes = CommandLineParser.GetArgumentValue(args, "randombytes", "").ToHexArray();
            var storage = new XmPackagingStorage();

            storage.Pack(p, outputFile);
        }
예제 #2
0
 private void buttonPackage_Click(object sender, EventArgs e)
 {
     this.saveFileDialog1.ClearFilter();
     this.saveFileDialog1.AddFilter("可执行文件", "*.exe");
     if (this.saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         try
         {
             GlobalContext.Project = Fetch();
             _storage.Pack(GlobalContext.Project, this.saveFileDialog1.FileName);
             MessageBox.Show("封包成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch (Exception ex)
         {
             MessageBox.Show("封包失败," + ex, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }