コード例 #1
0
        public static void Unregister()
        {
            RegHelp.RemoveKey(@"HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename);
            RegHelp.RemoveKey($"HKCR\\Applications\\{ExeFilename}");
            RegHelp.RemoveKey(@"HKLM\SOFTWARE\Clients\Media\mpv.net");
            RegHelp.RemoveKey($"HKCR\\SystemFileAssociations\\video\\OpenWithList\\{ExeFilename}");
            RegHelp.RemoveKey($"HKCR\\SystemFileAssociations\\audio\\OpenWithList\\{ExeFilename}");

            foreach (string id in Registry.ClassesRoot.GetSubKeyNames())
            {
                if (id.StartsWith(ExeFilenameNoExt + "."))
                    Registry.ClassesRoot.DeleteSubKeyTree(id);

                RegHelp.RemoveValue($"HKCR\\Software\\Classes\\" + id + "\\OpenWithProgIDs", ExeFilenameNoExt + id);
                RegHelp.RemoveValue($"HKLM\\Software\\Classes\\" + id + "\\OpenWithProgIDs", ExeFilenameNoExt + id);
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: Revan654/mpv.net
        protected override void WndProc(ref Message m)
        {
            //Debug.WriteLine(m);

            switch (m.Msg)
            {
            case 0x0201:     // WM_LBUTTONDOWN
            case 0x0202:     // WM_LBUTTONUP
            case 0x0100:     // WM_KEYDOWN
            case 0x0101:     // WM_KEYUP
            case 0x0104:     // WM_SYSKEYDOWN
            case 0x0105:     // WM_SYSKEYUP
            case 0x020A:     // WM_MOUSEWHEEL
                if (mp.WindowHandle != IntPtr.Zero)
                {
                    Native.SendMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
                }
                break;

            case 0x0200:     // WM_MOUSEMOVE
                Point pos = PointToClient(Cursor.Position);
                mp.command_string($"mouse {pos.X} {pos.Y}");
                if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
                {
                    CursorHelp.Show();
                }
                break;

            case 0x319:     // WM_APPCOMMAND
                if (mp.WindowHandle != IntPtr.Zero)
                {
                    Native.PostMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
                }
                break;

            case 0x203:     // Native.WM.LBUTTONDBLCLK
                if (!IsMouseInOSC())
                {
                    mp.command_string("cycle fullscreen");
                }
                break;

            case 0x02E0:     // WM_DPICHANGED
                if (IgnoreDpiChanged)
                {
                    break;
                }
                var r2 = Marshal.PtrToStructure <Native.RECT>(m.LParam);
                Native.SetWindowPos(Handle, IntPtr.Zero, r2.Left, r2.Top, r2.Width, r2.Height, 0);
                break;

            case 0x0214:     // WM_SIZING
                var rc = Marshal.PtrToStructure <Native.RECT>(m.LParam);
                var r  = rc;
                NativeHelp.SubtractWindowBorders(Handle, ref r);
                int   c_w = r.Right - r.Left, c_h = r.Bottom - r.Top;
                float aspect    = mp.VideoSize.Width / (float)mp.VideoSize.Height;
                int   d_w       = Convert.ToInt32(c_h * aspect - c_w);
                int   d_h       = Convert.ToInt32(c_w / aspect - c_h);
                int[] d_corners = { d_w, d_h, -d_w, -d_h };
                int[] corners   = { rc.Left, rc.Top, rc.Right, rc.Bottom };
                int   corner    = NativeHelp.GetResizeBorder(m.WParam.ToInt32());

                if (corner >= 0)
                {
                    corners[corner] -= d_corners[corner];
                }

                Marshal.StructureToPtr <Native.RECT>(new Native.RECT(corners[0], corners[1], corners[2], corners[3]), m.LParam, false);
                m.Result = new IntPtr(1);
                return;
            }

            if (m.Msg == SingleProcess.Message)
            {
                object filesObject = RegHelp.GetObject(App.RegPath, "ShellFiles");

                if (filesObject is string[] files)
                {
                    switch (RegHelp.GetString(App.RegPath, "ProcessInstanceMode"))
                    {
                    case "single":
                        mp.Load(files, true, Control.ModifierKeys.HasFlag(Keys.Control));
                        break;

                    case "queue":
                        foreach (string file in files)
                        {
                            mp.commandv("loadfile", file, "append");
                        }
                        break;
                    }
                }

                RegHelp.RemoveValue(App.RegPath, "ShellFiles");
                Activate();
                return;
            }

            base.WndProc(ref m);
        }