Esempio n. 1
0
 public static Task SetBG(string bg)
 {
     return(Task.Run(() =>
     {
         var result = USER32Wrapper.SystemParametersInfo(USER32Wrapper.SPI_SETDESKWALLPAPER, 0, new StringBuilder(bg), USER32Wrapper.SPIF_UPDATEINIFILE);
     }));
 }
Esempio n. 2
0
        private bool Initlize()
        {
            IntPtr progman = USER32Wrapper.FindWindow("Progman", null);
            IntPtr result  = IntPtr.Zero;

            USER32Wrapper.SendMessageTimeout(progman,
                                             0x052C,
                                             new IntPtr(0),
                                             IntPtr.Zero,
                                             SendMessageTimeoutFlags.SMTO_NORMAL,
                                             1000,
                                             out result);
            workerw = IntPtr.Zero;
            var result1 = USER32Wrapper.EnumWindows(new EnumWindowsProc((tophandle, topparamhandle) =>
            {
                IntPtr p = USER32Wrapper.FindWindowEx(tophandle,
                                                      IntPtr.Zero,
                                                      "SHELLDLL_DefView",
                                                      IntPtr.Zero);

                if (p != IntPtr.Zero)
                {
                    workerw = USER32Wrapper.FindWindowEx(IntPtr.Zero,
                                                         tophandle,
                                                         "WorkerW",
                                                         IntPtr.Zero);
                }

                return(true);
            }), IntPtr.Zero);

            return(result1);
        }
Esempio n. 3
0
 public static Task <string> GetCurrentBG()
 {
     return(Task.Run(() =>
     {
         StringBuilder wallPaperPath = new StringBuilder(200);
         var temp = USER32Wrapper.SystemParametersInfo(USER32Wrapper.SPI_GETDESKWALLPAPER, 200, wallPaperPath, 0);
         if (temp > 0)
         {
             return wallPaperPath.ToString();
         }
         return null;
     }));
 }
Esempio n. 4
0
        public virtual async Task Show(string appPath, string args)
        {
            if (string.IsNullOrEmpty(appPath))
            {
                return;
            }

            bool isOk = await Task.Run(() => Initlize());

            if (!isOk)
            {
                return;
            }

            KillOldProcess();

            _defaultBG = await ImgWallpaper.GetCurrentBG();


            string exeName = Path.GetFileName(appPath);
            bool   isInt   = int.TryParse(exeName, out int Pid);

            if (isInt)
            {
                process = Process.GetProcessById(Pid);
            }
            else
            {
                string name = Path.GetFileNameWithoutExtension(exeName);
                foreach (Process exe in Process.GetProcessesByName(name))
                {
                    try
                    {
                        if (exe.MainModule.FileName == exeName)
                        {
                            process = exe;
                            break;
                        }
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                if (process == null)
                {
                    ProcessStartInfo startInfo = new ProcessStartInfo(appPath)
                    {
                        WindowStyle = ProcessWindowStyle.Maximized
                    };
                    double width  = Screen.AllScreens[0].Bounds.Width;
                    double height = Screen.AllScreens[0].Bounds.Height;
                    startInfo.Arguments = $"{args} -popupwindow -screen-height {height} -screen-width {width}";
                    //startInfo.Arguments = $" -popupwindow -screen-width {y1}";
                    process = Process.Start(startInfo);
                }
            }
            cacheMainHandle = await TryGetMainWindowHandle(process);

            cacheParent = USER32Wrapper.GetParent(cacheMainHandle);
            USER32Wrapper.SetParent(cacheMainHandle, workerw);
        }