Exemple #1
0
        static void Main(string[] args)
        {
            if (isPortableBuild)
            {
                PathData = AppDomain.CurrentDomain.BaseDirectory;
            }
            else
            {
                PathData = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Lively Wallpaper");
            }

            int     livelyId;
            Process lively;

            if (args.Length == 0)
            {
                Console.WriteLine("NO arguments sent.");
                //Console.Read();
                return;
            }

            if (args.Length == 1)
            {
                try
                {
                    livelyId = Convert.ToInt32(args[0], 10);
                }
                catch
                {
                    Console.WriteLine("ERROR: converting toint");
                    //Console.Read();
                    return;
                }
            }
            else
            {
                Console.WriteLine("Incorrent no of arguments.");
                //Console.Read();
                return;
            }

            try
            {
                lively = Process.GetProcessById(livelyId);
            }
            catch
            {
                Console.WriteLine("getting processname failure, ignoring");
                //Console.Read();
                return;
            }

            if (!lively.ProcessName.Equals("livelywpf", StringComparison.InvariantCultureIgnoreCase))
            {
                Console.WriteLine("Error: Not livelywpf :- " + lively.ProcessName);
                //Console.Read();
                return;
            }

            lively.WaitForExit();

            Console.WriteLine("done waiting, ready to kill..");
            //Console.Read();

            FileHandle.LoadRunningPrograms();

            foreach (var proc in Process.GetProcesses())
            {
                Console.WriteLine("pgm list:- " + proc.ProcessName + " " + proc.MainWindowHandle);
                foreach (var wproc in FileHandle.runningPrograms)
                {
                    //Pid + Process-name is unique enough to make sure its the correct pgm.
                    if (proc.ProcessName.Equals(wproc.ProcessName, StringComparison.OrdinalIgnoreCase) && proc.Id == wproc.Pid)//&& IntPtr.Equals(proc.MainWindowHandle,wproc.handle))//proc.Handle == wproc.handle)
                    {
                        Console.WriteLine("Unclosed pgm, kill:- " + proc.ProcessName);
                        try
                        {
                            proc.Kill();
                        }
                        catch { }
                    }
                }
            }

            //force refresh desktop.
            SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, null, SPIF_UPDATEINIFILE);

            FileHandle.runningPrograms.Clear();
            FileHandle.SaveRunningPrograms();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            int     livelyId;
            Process lively;

            if (args.Length == 0)
            {
                Console.WriteLine("NO arguments sent.");
                //Console.Read();
                return;
            }

            if (args.Length == 1)
            {
                try
                {
                    livelyId = Convert.ToInt32(args[0], 10);
                }
                catch
                {
                    Console.WriteLine("ERROR: converting toint");
                    //Console.Read();
                    return;
                }
            }
            else
            {
                Console.WriteLine("Incorrent no of arguments.");
                //Console.Read();
                return;
            }

            try
            {
                lively = Process.GetProcessById(livelyId);
            }
            catch
            {
                Console.WriteLine("getting processname failure, ignoring");
                //Console.Read();
                return;
            }

            if (!lively.ProcessName.Equals("livelywpf", StringComparison.InvariantCultureIgnoreCase))
            {
                Console.WriteLine("Error: Not livelywpf :- " + lively.ProcessName);
                //Console.Read();
                return;
            }

            lively.WaitForExit();

            Console.WriteLine("done waiting, ready to kill *_*");
            //Console.Read();

            FileHandle.LoadRunningPrograms();

            foreach (var proc in Process.GetProcesses())
            {
                Console.WriteLine("pgm list:- " + proc.ProcessName + " " + proc.MainWindowHandle);
                foreach (var wproc in FileHandle.runningPrograms)
                {
                    if (proc.ProcessName.Equals(wproc.ProcessName, StringComparison.OrdinalIgnoreCase) && proc.Id == wproc.Pid)//&& IntPtr.Equals(proc.MainWindowHandle,wproc.handle))//proc.Handle == wproc.handle)
                    {
                        Console.WriteLine("Unclosed pgm, kill:- " + proc.ProcessName);
                        try
                        {
                            proc.Kill();
                        }
                        catch { }
                    }
                }
            }

            //force refresh desktop.
            SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, null, SPIF_UPDATEINIFILE);

            FileHandle.runningPrograms.Clear();
            FileHandle.SaveRunningPrograms();
        }