Exemplo n.º 1
0
        private void ConfigureAttacks(List <Tuple <Attack, List <Character>, Guid> > attacksToConfigure)
        {
            this.LoadAttackConfigurationWidget(attacksToConfigure);
            IntPtr foregroundWindow = WindowsUtilities.FindWindow(null, "MainWindow");

            WindowsUtilities.SetForegroundWindow(foregroundWindow);
        }
Exemplo n.º 2
0
 private async void ShowProperties(IntPtr owner)
 {
     using (var form = new Properties())
     {
         await WindowsUtilities.ShowModelessAsync(form, owner);
     }
 }
        private void PlayAnimatedAbility(AnimatedAbility ability)
        {
            Action d = delegate()
            {
                if (!ability.IsAttack)
                {
                    IntPtr winHandle = WindowsUtilities.FindWindow("CrypticWindow", null);
                    WindowsUtilities.SetForegroundWindow(winHandle);
                }

                Character currentTarget = null;
                if (!ability.PlayOnTargeted)
                {
                    this.SpawnAndTargetOwnerCharacter();
                    currentTarget = this.Owner;
                }
                else
                {
                    Roster.RosterExplorerViewModel rostExpVM = this.Container.Resolve <Roster.RosterExplorerViewModel>();
                    currentTarget = rostExpVM.GetCurrentTarget() as Character;
                    if (currentTarget == null)
                    {
                        this.SpawnAndTargetOwnerCharacter();
                        currentTarget = this.Owner;
                    }
                }
                owner.ActiveAbility = ability;
                currentTarget.Target();
                //ability.Play(Target: currentTarget);
                this.eventAggregator.GetEvent <PlayAnimatedAbilityEvent>().Publish(new Tuple <Character, AnimatedAbility>(currentTarget, ability));
            };
            AsyncDelegateExecuter adex = new Library.Utility.AsyncDelegateExecuter(d, 5);

            adex.ExecuteAsyncDelegate();
        }
Exemplo n.º 4
0
 internal static void navToWindowsUtilities(string val, string flag)
 {
     if (flag.Equals("listofservices"))
     {
         WindowsUtilities.getListOfWindowsServices();
     }
     else if (flag.Equals("servicenames"))
     {
         WindowsUtilities.setserviceNames(val);
     }
     else if (flag.Equals("servicestatus"))
     {
         WindowsUtilities.validateServiceStatus(val);
     }
     else if (flag.Equals("OpenFile"))
     {
         WindowsUtilities.readTextFile();
     }
     else if (flag.Equals("ValPayAmount"))
     {
         WindowsUtilities.ValPayAmount();
     }
     else if (flag.Equals("ftpGenfileLocation"))
     {
         WindowsUtilities.setftpGenFileLocation();
     }
 }
Exemplo n.º 5
0
        private void AddScreenButton_Click(object sender, RoutedEventArgs e)
        {
            var window = new SelectProcessWindow();

            if (window.ShowDialog() != true)
            {
                return;
            }

            var process = window.SelectedProcess;

            if (process == null)
            {
                return;
            }

            var(_, bitmap) = WindowsUtilities.GetScreenshotOfWindow(process.MainWindowHandle);
            if (bitmap == null)
            {
                MessageBox.Show("Error");
                return;
            }

            var path = Path.Combine(Settings.Default.CurrentDirectory, $"{process.ProcessName}_{new Random().Next()}.bmp");

            bitmap.Save(path, ImageFormat.Bmp);

            Load(Settings.Default.CurrentDirectory);
        }
Exemplo n.º 6
0
 private void OpenConfigurationBackupPathToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (IOUtilities.DirectoryExists(Settings.ConfigurationBackupDirectoryPath))
     {
         WindowsUtilities.OpenExplorer(Settings.ConfigurationBackupDirectoryPath);
     }
 }
Exemplo n.º 7
0
 private void OpenLogsPathToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (IOUtilities.DirectoryExists(Settings.LogsDirectoryPath))
     {
         WindowsUtilities.OpenExplorer(Settings.LogsDirectoryPath);
     }
 }
 private void ShowProperties(IntPtr owner) => TaskUtilities.EnsureSTAThreadTask(() =>
 {
     using (var form = new Properties())
     {
         WindowsUtilities.RunForm(form, owner);
     }
 });
Exemplo n.º 9
0
        public static void RegisterAsVirtualFolder(string extension, Guid shellFolderClassId)
        {
            if (extension == null)
            {
                throw new ArgumentNullException(nameof(extension));
            }

            const string classes = @"Software\Classes";
            string       progid  = null;

            using (var key = WindowsUtilities.EnsureSubKey(Registry.CurrentUser, Path.Combine(classes, extension)))
            {
                progid = (string)key.GetValue(null);
                if (string.IsNullOrWhiteSpace(progid))
                {
                    progid = typeof(Program).Namespace;
                    key.SetValue(null, progid);
                }
            }

            using (var key = WindowsUtilities.EnsureSubKey(Registry.CurrentUser, Path.Combine(classes, progid, "CLSID")))
            {
                SetStringKeyWithBackup(key, null, shellFolderClassId.ToString("B"));
            }

            using (var key = WindowsUtilities.EnsureSubKey(Registry.CurrentUser, Path.Combine(classes, progid, "shell", "open", "command")))
            {
                SetStringKeyWithBackup(key, null, @"%SystemRoot%\explorer.exe /idlist,%I,%L");

                // this is CLSID_ExecuteFolder from shobjidl.h
                var CLSID_ExecuteFolder = new Guid("11dbb47c-a525-400b-9e80-a54615a090c0");
                SetStringKeyWithBackup(key, "DelegateExecute", CLSID_ExecuteFolder.ToString("B"));
            }
        }
Exemplo n.º 10
0
        public static void Browse(string url)
        {
            if (string.IsNullOrWhiteSpace(url))
            {
                return;
            }

            WindowsUtilities.OpenDefaultBrowser(url);
        }
Exemplo n.º 11
0
 private void ResetGameWindow(object sender, RoutedEventArgs e)
 {
     if (gameWindowHandler != IntPtr.MaxValue)
     {
         WindowsUtilities.SetWindowPos(gameWindowHandler,
                                       gameConfig.WindowArea.X, gameConfig.WindowArea.Y,
                                       gameConfig.WindowArea.Width, gameConfig.WindowArea.Height);
         StatusBlock.Text = "Game window info saved";
     }
 }
        protected override async void HandleInformationBarMenu(InformationBar bar, IntPtr hwndOwner, int id)
        {
            if (id == 1) // first item has id 1, etc.
            {
                await WindowsUtilities.DoModelessAsync(() =>
                {
                    System.Windows.Forms.MessageBox.Show(new Win32Window(hwndOwner), "UAC level is " + DiagnosticsInformation.GetTokenElevationType(), "Registry Folder");
                });

                return;
            }
        }
Exemplo n.º 13
0
        private async void OnRename(ShellOperationEventArgs e)
        {
            if (e.Item.IsFolder)
            {
                // rename a key
                using (var key = OpenKey(true))
                {
                    if (key != null)
                    {
                        var path = System.IO.Path.Combine(Path ?? string.Empty, e.Item.DisplayName);
                        RegRenameKey(key.Handle, path, e.NewName);
                        e.NewId = new StringKeyShellItemId(e.NewName);
                        e.Item.NotifyRename(e.NewId);
                        e.HResult = ShellUtilities.S_OK;
                    }
                }
                return;
            }

            // rename a value (delete + set)
            using (var key = OpenKey(true))
            {
                if (key != null)
                {
                    if (key.GetValueNames().Contains(e.NewName, StringComparer.OrdinalIgnoreCase))
                    {
                        await WindowsUtilities.DoModelessAsync(() =>
                        {
                            MessageBox.Show(new Win32Window(e.HwndOwner), "The Registry Folder cannot rename '" + e.Item.DisplayName + "'. The specified value name already exists. Type another name and try again.", "Registry Folder", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        });
                    }
                    else
                    {
                        var value = key.GetValue(e.Item.DisplayName);
                        if (value == null)
                        {
                            await WindowsUtilities.DoModelessAsync(() =>
                            {
                                MessageBox.Show(new Win32Window(e.HwndOwner), "The Registry Folder cannot rename '" + e.Item.DisplayName + "'. The specified value name does not exists. Refresh the view and try again.", "Registry Folder", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            });
                        }
                        else
                        {
                            key.SetValue(e.NewName, value);
                            key.DeleteValue(e.Item.DisplayName, false);
                            e.NewId   = new StringKeyShellItemId(e.NewName);
                            e.HResult = ShellUtilities.S_OK;
                            e.Item.Parent?.NotifyUpdate();
                        }
                    }
                }
            }
        }
Exemplo n.º 14
0
        private Bitmap CurrentGameBitmap()
        {
            var windowArea       = WindowsUtilities.GetWindowArea(gameWindowHandler);
            var absoluteGameArea = new Rectangle()
            {
                X      = windowArea.X + gameConfig.GameArea.X,
                Y      = windowArea.Y + gameConfig.GameArea.Y,
                Width  = gameConfig.GameArea.Width,
                Height = gameConfig.GameArea.Height
            };

            return(BitmapUtilities.CaptureGame(absoluteGameArea, Processor.ProcessingSize));
        }
        protected async override void OnDragDropTarget(DragDropTargetEventArgs e)
        {
            e.Effect = DragDropEffects.Copy;
            if (e.Type == DragDropTargetEventType.DragDrop)
            {
                // you can use other formats but this one is the only one that contains PIDLs
                var list = string.Join(Environment.NewLine, e.DataObject.ItemsIdLists.Select(id => id.GetName(Core.WindowsShell.SIGDN.SIGDN_NORMALDISPLAY)));

                await WindowsUtilities.DoModelessAsync(() =>
                {
                    MessageBox.Show(null, "UAC level is " + DiagnosticsInformation.GetTokenElevationType(), "Registry Folder");
                });
            }
        }
 internal IntPtr HandleKeyboardEvent(int nCode, IntPtr wParam, IntPtr lParam)
 {
     if (nCode >= 0)
     {
         KBDLLHOOKSTRUCT keyboardLLHookStruct = (KBDLLHOOKSTRUCT)(Marshal.PtrToStructure(lParam, typeof(KBDLLHOOKSTRUCT)));
         this.vkCode = (Keys)keyboardLLHookStruct.vkCode;
         KeyboardMessage wmKeyboard = (KeyboardMessage)wParam;
         if ((wmKeyboard == KeyboardMessage.WM_KEYDOWN || wmKeyboard == KeyboardMessage.WM_SYSKEYDOWN))
         {
             IntPtr foregroundWindow = WindowsUtilities.GetForegroundWindow();
             uint   wndProcId;
             uint   wndProcThread = WindowsUtilities.GetWindowThreadProcessId(foregroundWindow, out wndProcId);
             if (foregroundWindow == WindowsUtilities.FindWindow("CrypticWindow", null) ||
                 Process.GetCurrentProcess().Id == wndProcId)
             {
                 System.Windows.Input.Key inputKey = InputKey;
                 if ((inputKey == Key.Left || inputKey == Key.Right) && Keyboard.Modifiers == ModifierKeys.Control)
                 {
                     IntPtr winHandle = WindowsUtilities.FindWindow("CrypticWindow", null);
                     WindowsUtilities.SetForegroundWindow(winHandle);
                 }
                 else
                 {
                     lock (lockObj)
                     {
                         try
                         {
                             foreach (HandleKeyEvent _handleKeyEvent in _handleKeyEvents)
                             {
                                 EventMethod handler = _handleKeyEvent(vkCode, inputKey);
                                 if (handler != null)
                                 {
                                     handler();
                                 }
                             }
                         }
                         catch (Exception ex)
                         {
                         }
                     }
                 }
             }
         }
     }
     return(CallNextHook(hookID, nCode, wParam, lParam));
 }
        private void Details_Click(object sender, RoutedEventArgs e)
        {
            const string CopyName = "Copy";

            if (CopyName.Equals(Details.Content))
            {
                Clipboard.SetText(ErrorDetails.Text);
                return;
            }

            Details.Content         = CopyName;
            ErrorDetails.Visibility = Visibility.Visible;
            Dispatcher.BeginInvoke(() =>
            {
                WindowsUtilities.CenterWindow(new WindowInteropHelper(this).Handle);
            }, DispatcherPriority.Background);
        }
Exemplo n.º 18
0
        private void OverwriteGameWindowArea(object sender, RoutedEventArgs e)
        {
            if (gameWindowHandler != IntPtr.MaxValue)
            {
                var windowRect = WindowsUtilities.GetWindowArea(gameWindowHandler);
                gameConfig.WindowArea = windowRect;

                if (gameConfig.GameArea.Width > windowRect.Width || gameConfig.GameArea.Height > windowRect.Height)
                {
                    var ratio          = (double)Processor.ProcessingSize.Width / Processor.ProcessingSize.Height;
                    var gameAreaY      = 57;
                    var gameAreaHeight = windowRect.Height - 60;
                    var gameAreaWidth  = (int)(gameAreaHeight * ratio);
                    var gameAreaX      = (windowRect.Width - gameAreaWidth) / 2;
                    gameConfig.GameArea = new(gameAreaX, gameAreaY, gameAreaWidth, gameAreaHeight);
                }

                gameConfig.SaveConfig();
                StatusBlock.Text = "Game window info saved";
            }
        }
Exemplo n.º 19
0
        private void OnRootProperties(object sender, ShellMenuInvokeEventArgs e)
        {
            var ctx = ShellContext.Current.Clone();

            TaskUtilities.EnsureSTAThreadTask(() =>
            {
                // find the top view window handle
                var viewHandle = Core.WindowsShell.View.GetOwnerViewHandle(e.HwndOwner);
                using (var form = new RootProperties())
                {
                    form.MemoryCacheCleared += (s, e2) =>
                    {
                        WebApi.ClearCache();
                    };
                    // use native proxy's 32x32 icon
                    form.Icon           = FolderServer.NativeProxy.Icons.FirstOrDefault(i => i.Height == 32).ToIcon();
                    form.SelectedObject = WebApi.ServerInfo;
                    WindowsUtilities.RunForm(form, viewHandle);
                }
            });
        }
Exemplo n.º 20
0
        private void Details_Click(object sender, RoutedEventArgs e)
        {
            if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
            {
                WpfExtensions.MailTo(null, "SSB Error: " + Error.Text, GetDebugInformation() + Environment.NewLine + ErrorDetails.Text);
                return;
            }
            const string CopyName = "Copy";

            if (CopyName.Equals(Details.Content))
            {
                Clipboard.SetText(ErrorDetails.Text);
                return;
            }

            Details.Content         = CopyName;
            ErrorDetails.Visibility = Visibility.Visible;
            Dispatcher.BeginInvoke(() =>
            {
                WindowsUtilities.CenterWindow(new WindowInteropHelper(this).Handle);
            }, DispatcherPriority.Background);
        }
Exemplo n.º 21
0
        private async void DispatcherTimer_TickAsync(object sender, EventArgs e)
        {
            try
            {
                IntPtr handler = WindowsUtilities.GetActiveWindowHandler();

                if (gameWindowHandler == IntPtr.MaxValue)
                {
                    var targetTitle = WindowsUtilities.GetWindowTitle(handler)?.Trim();
                    if (targetTitle?.Contains(gameConfig.WindowTitle) == true && targetTitle != TitleText)
                    {
                        gameWindowHandler = handler;
                        StatusBlock.Text  = "Game window detected";
                    }
                }

                if (handler == gameWindowHandler && WindowState == WindowState.Normal)
                {
                    using Bitmap gameBm = CurrentGameBitmap();

                    if (await TranslateAndUpdateTextBlocksAsync(await p.OCRChoicesAsync(gameBm)))
                    {
                        StatusBlock.Text = "Choices";
                        return;
                    }
                    else if (await TranslateAndUpdateTextBlocksAsync(await p.OCRStoryDialogueAsync(gameBm)))
                    {
                        StatusBlock.Text = "Story";
                        return;
                    }
                }
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc);
            }
        }
Exemplo n.º 22
0
        protected override void OnDragDropTarget(DragDropTargetEventArgs e)
        {
            e.HResult = ShellUtilities.S_OK;
            var paths = GetPaths(e);

            if (paths.Count > 0)
            {
                e.Effect = DragDropEffects.All;
            }

            if (e.Type == DragDropTargetEventType.DragDrop)
            {
                // file operation events need an STA thread
                WindowsUtilities.DoModelessAsync(() =>
                {
                    using (var fo = new FileOperation(true))
                    {
                        fo.PostCopyItem += (sender, e2) =>
                        {
                            // we could add some logic here
                        };

                        if (paths.Count == 1)
                        {
                            fo.CopyItem(paths[0], FileSystemPath, null);
                        }
                        else
                        {
                            fo.CopyItems(paths, FileSystemPath);
                        }
                        fo.SetOperationFlags(FOF.FOF_ALLOWUNDO | FOF.FOF_NOCONFIRMMKDIR | FOF.FOF_RENAMEONCOLLISION);
                        fo.PerformOperations();
                        NotifyUpdate();
                    }
                });
            }
        }
        internal IntPtr HandleMouseEvent(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                if (MouseMessage.WM_LBUTTONDOWN == (MouseMessage)wParam)
                {
                    MouseClickCount++;
                    switch (MouseClickCount)
                    {
                    case 1:
                        MouseState = DesktopMouseState.LEFT_CLICK;
                        if (IsDesktopActive)
                        {
                            needToHandleSingleClick = true;
                        }
                        Action action = delegate()
                        {
                            DoubleTripleQuadMouseClicksTracker.Start();
                        };
                        System.Windows.Application.Current.Dispatcher.Invoke(action);
                        break;

                    case 2:
                        MouseState = DesktopMouseState.DOUBLE_CLICK;
                        needToHanldeDoubleClick = true;
                        needToHandleSingleClick = false;
                        break;
                        //case 3: MouseState = DesktopMouseState.TRIPLE_CLICK; break;
                        //case 4: MouseState = DesktopMouseState.QUAD_CLICK; break;
                    }
                }
                else if (MouseMessage.WM_RBUTTONDOWN == (MouseMessage)wParam)
                {
                    MouseState = DesktopMouseState.RIGHT_CLICK;
                }
                else if (MouseMessage.WM_RBUTTONUP == (MouseMessage)wParam)
                {
                    MouseState = DesktopMouseState.RIGHT_CLICK_UP;
                }
                //else if (MouseMessage.WM_LBUTTONUP == (MouseMessage)wParam)
                //{
                //    if (!needToHanldeDoubleClick)
                //    {
                //        MouseState = DesktopMouseState.LEFT_CLICK_UP;
                //    }
                //}
                else if (MouseMessage.WM_MOUSEMOVE == (MouseMessage)wParam)
                {
                    MouseState = DesktopMouseState.MOUSE_MOVE;
                }
                Action d = delegate()
                {
                    IntPtr foregroundWindow = WindowsUtilities.GetForegroundWindow();
                    if (foregroundWindow == WindowsUtilities.FindWindow("CrypticWindow", null))
                    {
                        if (MouseState == DesktopMouseState.MOUSE_MOVE)
                        {
                            FireMouseMoveEvent();
                        }
                        else if (MouseState == DesktopMouseState.RIGHT_CLICK)
                        {
                            FireMouseRightClick();
                        }
                        else if (MouseState == DesktopMouseState.LEFT_CLICK)
                        {
                            if (needToHandleSingleClick)
                            {
                                FireMouseLeftClick();
                            }
                        }
                        //else if (MouseState == DesktopMouseState.LEFT_CLICK_UP)
                        //{
                        //    FireMouseLeftClickUp();
                        //}
                        else if (MouseState == DesktopMouseState.RIGHT_CLICK_UP)
                        {
                            FireMouseRightClickUp();
                        }
                        else if (MouseState == DesktopMouseState.DOUBLE_CLICK)
                        {
                            if (needToHanldeDoubleClick)
                            {
                                FireMouseDoubleClick();
                            }
                        }
                    }
                };

                AsyncDelegateExecuter adex = new AsyncDelegateExecuter(d, 50);
                adex.ExecuteAsyncDelegate();
            }
            return(MouseHook.CallNextHookEx(mouseHookID, nCode, wParam, lParam));
        }
Exemplo n.º 24
0
        private async void OnShellMenuItemInvoke(object sender, ShellMenuInvokeEventArgs e)
        {
            // e.MenuItem can be null for standard commands
            var menu = (ShellMenu)sender;

            // log something (if a logger is configured)
            menu.Server.Configuration?.Logger?.Log(TraceLevel.Info, "Shell Item '" + e.MenuItem + "' (cmd:" + e.Command + ") called.");

            var mc = Conversions.ChangeType(e.MenuItem?.Tag, MenuCommand.Unknown);

            switch (mc)
            {
            case MenuCommand.Modify:
                if (e.Items.Count == 1)                // we only support modification of one value at a time
                {
                    using (var form = new EditValue()) // note because of async + await, Dispose will happen in continuing task
                    {
                        var valueItem = (RegistryValueItem)e.Items[0];
                        form.LoadEditor(BaseParent.Hive, Path, valueItem.KeyName);
                        await WindowsUtilities.ShowModelessAsync(form, e.HwndOwner).ContinueWith((task) =>
                        {
                            if (task.Result == DialogResult.OK)
                            {
                                using (var key = OpenKey(true))
                                {
                                    key.SetValue(valueItem.KeyName, form.NewValue);
                                    valueItem.Parent?.NotifyUpdate();
                                }
                            }
                        });
                    }
                    return;
                }
                break;

            case MenuCommand.NewKey:
                using (var key = OpenKey(true))
                {
                    if (key != null)
                    {
                        var newName = GetNewName("New Key #", key.GetSubKeyNames());
                        try
                        {
                            key.CreateSubKey(newName);
                            e.Folder.RefreshShellViews();
                            await SelectAndEdit(newName);
                        }
                        catch (Exception ex)
                        {
                            // probably an access denied error
                            await WindowsUtilities.DoModelessAsync(() =>
                            {
                                MessageBox.Show(new Win32Window(e.HwndOwner), "The Registry Folder cannot set a value here: " + ex.Message, "Registry Folder", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            });
                        }
                    }
                }
                break;

            case MenuCommand.NewValueString:
            case MenuCommand.NewValueBinary:
            case MenuCommand.NewValueDWord:
            case MenuCommand.NewValueQWord:
            case MenuCommand.NewValueMultiString:
            case MenuCommand.NewValueExpandString:
                var kind = (RegistryValueKind)mc;
                using (var key = OpenKey(true))
                {
                    if (key != null)
                    {
                        var newName = GetNewName("New Value #", key.GetValueNames());
                        try
                        {
                            key.SetValue(newName, GetDefaultValue(kind), kind);
                            e.Folder.RefreshShellViews();
                            await SelectAndEdit(newName);
                        }
                        catch (Exception ex)
                        {
                            // probably an access denied error
                            await WindowsUtilities.DoModelessAsync(() =>
                            {
                                MessageBox.Show(new Win32Window(e.HwndOwner), "The Registry Folder cannot set a value here: " + ex.Message, "Registry Folder", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            });
                        }
                    }
                }
                break;
            }
        }
Exemplo n.º 25
0
        // https://stackoverflow.com/questions/23777688/pin-a-folder-to-navigation-pane-in-windows-explorer/34737590
        // register as a cloud provider in explorer tree view
        public static void RegisterCloudStorageProvider(string folderPath, string displayName, Guid id, string iconPath = null, int sortOrderIndex = 30)
        {
            if (folderPath == null)
            {
                throw new ArgumentNullException(nameof(folderPath));
            }

            if (displayName == null)
            {
                throw new ArgumentNullException(nameof(displayName));
            }

            if (id == Guid.Empty)
            {
                throw new ArgumentException(null, nameof(id));
            }

            using (var key = WindowsUtilities.EnsureSubKey(Registry.CurrentUser, Path.Combine(@"Software\Classes\CLSID", id.ToString("B"))))
            {
                key.SetValue(null, displayName);
                key.SetValue("System.IsPinnedToNameSpaceTree", 1);
                key.SetValue("SortOrderIndex", sortOrderIndex);

                using (var icon = WindowsUtilities.EnsureSubKey(key, "DefaultIcon"))
                {
                    var path = iconPath.Nullify() ?? NativeProxy.Default.DllPath;
                    icon.SetValue(null, path);
                }

                using (var server = WindowsUtilities.EnsureSubKey(key, "InProcServer32"))
                {
                    server.SetValue(null, @"%systemroot%\system32\shell32.dll");
                }

                using (var folder = WindowsUtilities.EnsureSubKey(key, "ShellFolder"))
                {
                    var attributes = SFGAO.SFGAO_HASSUBFOLDER |
                                     SFGAO.SFGAO_CANCOPY |
                                     SFGAO.SFGAO_CANLINK |
                                     SFGAO.SFGAO_STORAGE |
                                     SFGAO.SFGAO_HASPROPSHEET |
                                     SFGAO.SFGAO_STORAGEANCESTOR |
                                     SFGAO.SFGAO_FILESYSANCESTOR |
                                     SFGAO.SFGAO_FOLDER |
                                     SFGAO.SFGAO_FILESYSTEM;
                    folder.SetValue("Attributes", (int)attributes);
                    folder.SetValue("FolderValueFlags", 0x28);
                }

                using (var instance = WindowsUtilities.EnsureSubKey(key, "Instance"))
                {
                    var CLSID_FileFolderBoth = new Guid("{0E5AAE11-A475-4C5b-AB00-C66DE400274E}");
                    instance.SetValue("CLSID", CLSID_FileFolderBoth.ToString("B"));

                    using (var bag = WindowsUtilities.EnsureSubKey(instance, "InitPropertyBag"))
                    {
                        bag.SetValue("Attributes", 0x11);
                        bag.SetValue("TargetFolderPath", folderPath);
                    }
                }
            }

            using (var key = WindowsUtilities.EnsureSubKey(Registry.CurrentUser, Path.Combine(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace", id.ToString("B"))))
            {
                key.SetValue(null, displayName);
            }

            using (var key = WindowsUtilities.EnsureSubKey(Registry.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel"))
            {
                key.SetValue(id.ToString("B"), 1);
            }
        }
Exemplo n.º 26
0
 private void OpenPath_Click(object sender, RoutedEventArgs e) => WindowsUtilities.OpenExplorer(UIUtilities.GetDataContext <DriveService>(sender).RootPath);
Exemplo n.º 27
0
 public static BitmapSource GetStockIcon(WindowsUtilities.StockIconId id, WindowsUtilities.SHGSI flags)
 {
     return(Imaging.CreateBitmapSourceFromHIcon(WindowsUtilities.GetStockIcon(id, flags).Handle, Int32Rect.Empty, null));
 }