Ejemplo n.º 1
0
        public void Install()
        {
            var expectedSignature = AppOnlineSignature;
            var appDownloaded     = AppDir.Update.AddPath(expectedSignature.Path);

            BeginInstall?.Invoke();

            if (new SevenZip(silent: false).Extract(appDownloaded, AppDir.Root, _protectedFiles))
            {
                EndInstall?.Invoke();
                writeInstalledVersion(expectedSignature.Path);
                CreateApplicationShortcut(AppDir.Root);
                updateApplicationShortcut(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
                Console.WriteLine();

                Console.WriteLine("Upgrade complete!");
                Console.WriteLine("Restart Mtgdb.Gui to enjoy new version immediately :)");
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine($"Failed to extract new version files from {appDownloaded}.");
                Console.WriteLine("I apologize. I hoped it will never happen, but here we are :(");
                Console.WriteLine();
                Console.WriteLine("However you should be able to run the current version normally.");
                Console.WriteLine("If it's not the case you can");
                Console.WriteLine("\t* Re-download and manually install Mtgdb.Gui");
                Console.WriteLine("\t* Report the problem and get help at https://www.slightlymagic.net/forum/viewtopic.php?f=15&t=19298&sid=02dfce1282b368b1b8f40d452ac0af18");
                Console.WriteLine();
            }
        }
Ejemplo n.º 2
0
        public void Install(Action onComplete)
        {
            var expectedSignature = AppOnlineSignature;
            var appDownloaded     = AppDir.Update.Join(expectedSignature.Path);

            BeginInstall?.Invoke();

            if (new SevenZip(silent: false).Extract(appDownloaded, AppDir.Root, _protectedFiles))
            {
                EndInstall?.Invoke();
                writeInstalledVersion(expectedSignature.Path.Value);
                CreateApplicationShortcut(AppDir.Root);
                updateApplicationShortcut(new FsPath(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)));
                Console.WriteLine();

                onComplete?.Invoke();

                Console.WriteLine("Installed version will run next time you start Mtgdb.Gui");
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine($"Failed to extract new version files from {appDownloaded}.");
                Console.WriteLine("It should never happen, but here we are :(");
                Console.WriteLine();
                Console.WriteLine("However you should be able to run the current version normally.");
                Console.WriteLine("If you can't:");
                Console.WriteLine("\t* Re-download and manually install Mtgdb.Gui");
                Console.WriteLine("\t* Report the problem and get help at https://www.slightlymagic.net/forum/viewtopic.php?f=15&t=19298&sid=02dfce1282b368b1b8f40d452ac0af18");
                Console.WriteLine();
            }
        }
Ejemplo n.º 3
0
        static int Main(string[] args)
        {
            try
            {
                string folder = getFolder();
                errorLog("install to path:" + folder);
                if (args.Length == 0)
                {
                    Application.EnableVisualStyles();
                    Application.Run(new Form1());
                }
                else
                {
                    string msg = "";



                    msg = string.Format("Argument: {0}", args[0]);
                    errorLog(msg);
                    string[] s = args[0].Split('|');
                    if (s.Length != 2)
                    {
                        errorLog("Wrong argument");
                        return(-1);
                    }
                    string sDll = s[1];
                    sDll = sDll.Replace("AddOnInstallAPI.dll", "AddOnInstallAPI_x64.dll");

                    IntPtr pDll = NativeMethods.LoadLibrary(sDll);
                    IntPtr pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pDll, "SetAddOnFolder");
                    //if(pAddressOfFunctionToCall == IntPtr.Zero)

                    SetAddOnFolder setAddOnFolder = (SetAddOnFolder)Marshal.GetDelegateForFunctionPointer(
                        pAddressOfFunctionToCall,
                        typeof(SetAddOnFolder));

                    int theResult = setAddOnFolder(folder);

                    errorLog("setAddOnFolder return " + theResult.ToString() + "\r\nFolder:" + folder);



                    pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pDll, "EndInstall");
                    //if(pAddressOfFunctionToCall == IntPtr.Zero)

                    EndInstall endInstall = (EndInstall)Marshal.GetDelegateForFunctionPointer(
                        pAddressOfFunctionToCall,
                        typeof(EndInstall));

                    theResult = endInstall();
                    errorLog("EndInstall return " + theResult.ToString());


                    bool result = NativeMethods.FreeLibrary(pDll);
                    errorLog("Installation completed.");
                    // MessageBox.Show("eBizCharge Install Completed.");
                }
            }catch (Exception ex)
            {
                errorLog(ex);
            }
            return(0);
        }