/// <summary> /// Plays the specified system sound using the audio session for system notification sounds. /// </summary> /// <param name="app">The name of the app that the sound belongs to. For example, ".Default" contains system sounds, "Explorer" contains Explorer sounds.</param> /// <param name="name">The name of the system sound to play.</param> public static bool PlaySystemSound(string app, string name) { try { using (RegistryKey key = Registry.CurrentUser.OpenSubKey($"{SYSTEM_SOUND_ROOT_KEY}\\{app}\\{name}\\.Current")) { if (key == null) { ShellLogger.Error($"SoundHelper: Unable to find sound {name} for app {app}"); return(false); } if (key.GetValue(null) is string soundFileName) { if (string.IsNullOrEmpty(soundFileName)) { ShellLogger.Error($"SoundHelper: Missing file for sound {name} for app {app}"); return(false); } return(PlaySound(soundFileName, IntPtr.Zero, (uint)(SND_ASYNC | SND_FILENAME | SND_SYSTEM))); } else { ShellLogger.Error($"SoundHelper: Missing file for sound {name} for app {app}"); return(false); } } } catch (Exception e) { ShellLogger.Error($"SoundHelper: Unable to play sound {name} for app {app}: {e.Message}"); return(false); } }
private static IImageList imlJumbo; // 256pt private static void initIml(IconSize size) { // Initialize the appropriate IImageList for the desired icon size if it hasn't been already if (size == IconSize.Large && imlLarge == null) { SHGetImageList((int)size, ref iidImageList, out imlLarge); } else if (size == IconSize.Small && imlSmall == null) { SHGetImageList((int)size, ref iidImageList, out imlSmall); } else if (size == IconSize.ExtraLarge && imlExtraLarge == null) { SHGetImageList((int)size, ref iidImageList, out imlExtraLarge); } else if (size == IconSize.Jumbo && imlJumbo == null) { SHGetImageList((int)size, ref iidImageList, out imlJumbo); } else if (size != IconSize.Small && size != IconSize.Large && size != IconSize.ExtraLarge && size != IconSize.Jumbo) { ShellLogger.Error($"IconHelper: Unsupported icon size {size}"); } }
private void checkRunAtLogOn() { if (EnvironmentHelper.IsAppConfiguredAsShell.Equals(true)) { chkRunAtLogOn.Visibility = Visibility.Collapsed; } try { RegistryKey rKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", false); List <string> rKeyValueNames = rKey?.GetValueNames().ToList(); if (rKeyValueNames != null) { if (rKeyValueNames.Contains("CairoShell")) { chkRunAtLogOn.IsChecked = true; } else { chkRunAtLogOn.IsChecked = false; } } } catch (Exception e) { ShellLogger.Error($"SettingsWindow: Unable to load autorun setting from registry: {e.Message}"); } }
protected void UpdateSelfPhone(object sender, GridViewUpdateEventArgs e) { var GridView1 = (GridView)EmployeeFormView.FindControl("GridView2"); var SpecificStaffPlaceId = (Guid)e.Keys[0]; string currentPhoneNumber = ((TextBox)GridView1.Rows[e.RowIndex] .FindControl("txtCompanyName1")).Text; string currentPhoneType = ((DropDownList)GridView1.Rows[e.RowIndex] .FindControl("PhoneTypeDropDownList5")).SelectedValue; string commandText = "update SpecificStaffPlace set PhoneTypeId='" + currentPhoneType + "',PhoneNumber='" + currentPhoneNumber + "' where Id='" + SpecificStaffPlaceId + "'"; SqlConnection connection = DBHelper.GetConnection(); var cmd = new SqlCommand(commandText, connection) { CommandType = CommandType.Text }; try { connection.Open(); cmd.ExecuteNonQuery(); } catch (Exception ex) { ShellLogger.WriteLog("DB.log", "Ошибка обновления стационарного номера", ex); } finally { connection.Close(); } }
protected void AddNewSelfPhone(object sender, EventArgs e) { var PhoneTypeDDL = (DropDownList)EmployeeFormView.FindControl("DropDownList2"); var regionList2 = (DropDownList)EmployeeFormView.FindControl("RegionList3"); var SpecificStaffDDL = (DropDownList)EmployeeFormView.FindControl("SpecificStaffDDL"); var txtContactName = (TextBox)EmployeeFormView.FindControl("TextBox1"); var locationId = new Guid(regionList2.SelectedValue); var phoneTypeId = new Guid(PhoneTypeDDL.SelectedValue); var specificStaffId = new Guid(SpecificStaffDDL.SelectedValue); string phone = txtContactName.Text; string commandText = "insert into SpecificStaffPlace(Id,SpecificStaffId,LocationId,PhoneTypeId,PhoneNumber) values ('" + Guid.NewGuid() + "','" + specificStaffId + "','" + locationId + "','" + phoneTypeId + "','" + phone + "')"; SqlConnection connection = DBHelper.GetConnection(); var cmd = new SqlCommand(commandText, connection) { CommandType = CommandType.Text }; try { connection.Open(); cmd.ExecuteNonQuery(); EmployeeFormView.DataBind(); } catch (Exception ex) { ShellLogger.WriteLog("DB.log", "Ошибка добавления стационарного номера", ex); } finally { connection.Close(); } }
public ChangeWatcher(List <string> pathList, FileSystemEventHandler changedEventHandler, FileSystemEventHandler createdEventHandler, FileSystemEventHandler deletedEventHandler, RenamedEventHandler renamedEventHandler) { if (pathList == null || pathList.Count < 1) { return; } _changedEventHandler = changedEventHandler; _createdEventHandler = createdEventHandler; _deletedEventHandler = deletedEventHandler; _renamedEventHandler = renamedEventHandler; try { foreach (string path in pathList) { FileSystemWatcher watcher = new FileSystemWatcher(path) { NotifyFilter = NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastWrite | NotifyFilters.Size }; watcher.Changed += _changedEventHandler; watcher.Created += _createdEventHandler; watcher.Deleted += _deletedEventHandler; watcher.Renamed += _renamedEventHandler; _watchers.Add(watcher); } } catch (Exception e) { ShellLogger.Error($"ChangeWatcher: Unable to instantiate watcher: {e.Message}"); } }
private void ChangedEventHandler(object sender, FileSystemEventArgs e) { Task.Factory.StartNew(() => { ShellLogger.Info($"ShellFolder: Item {e.ChangeType}: {e.Name} ({e.FullPath})"); bool exists = false; foreach (var file in Files) { if (_isDisposed) { break; } if (file.Path == e.FullPath) { exists = true; file.Refresh(); break; } } if (!exists) { AddFile(e.FullPath); } }, CancellationToken.None, TaskCreationOptions.None, Interop.ShellItemScheduler); }
private SafeNotifyIconData GetTrayItemIconData(TrayItem trayItem) { SafeNotifyIconData nid = new SafeNotifyIconData(); nid.hWnd = trayItem.hWnd; nid.uID = trayItem.uID; nid.uCallbackMessage = trayItem.uCallbackMessage; nid.szTip = trayItem.szIconText; nid.hIcon = trayItem.hIcon; nid.uVersion = trayItem.uVersion; nid.guidItem = trayItem.guidItem; nid.dwState = (int)trayItem.dwState; nid.uFlags = NIF.GUID | NIF.MESSAGE | NIF.TIP | NIF.STATE; if (nid.hIcon != IntPtr.Zero) { nid.uFlags |= NIF.ICON; } else { ShellLogger.Warning($"ExplorerTrayService: Unable to use {trayItem.szIconText} icon handle for NOTIFYICONDATA struct"); } return(nid); }
private bool GetAutoTrayEnabled() { int enableAutoTray = 1; try { RegistryKey explorerKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer", false); if (explorerKey != null) { var enableAutoTrayValue = explorerKey.GetValue("EnableAutoTray"); if (enableAutoTrayValue != null) { enableAutoTray = Convert.ToInt32(enableAutoTrayValue); } } } catch (Exception e) { ShellLogger.Debug($"ExplorerTrayService: Unable to get EnableAutoTray setting: {e.Message}"); } return(enableAutoTray == 1); }
private IntPtr pathToRelPidl(string path) { IntPtr pidl; uint pchEaten = 0; ShellFolders.SFGAO pdwAttributes = 0; string file = Path.GetFileName(path); if (parentShellFolder != null) { int result = parentShellFolder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, file, ref pchEaten, out pidl, ref pdwAttributes); if (pidl == IntPtr.Zero) { ShellLogger.Debug("HRESULT " + result + " retrieving pidl for " + path); } return(pidl); } else { ShellLogger.Debug("Parent IShellFolder for " + path + " is null"); return(IntPtr.Zero); } }
public void SetVisibility(BalloonVisibility visibility) { if (NotifyIcon == null) { ShellLogger.Error("NotificationBalloon: NotifyIcon is null"); return; } switch (visibility) { case BalloonVisibility.Visible: NotifyIcon.SendMessage((uint)NIN.BALLOONSHOW, 0); break; case BalloonVisibility.Hidden: NotifyIcon.SendMessage((uint)NIN.BALLOONHIDE, 0); break; case BalloonVisibility.TimedOut: NotifyIcon.SendMessage((uint)NIN.BALLOONTIMEOUT, 0); break; default: break; } }
private void RegisterTrayWnd() { ushort trayClassReg = RegisterWndClass(TrayWndClass); if (trayClassReg == 0) { ShellLogger.Info($"TrayService: Error registering {TrayWndClass} class ({Marshal.GetLastWin32Error()})"); } HwndTray = CreateWindowEx( ExtendedWindowStyles.WS_EX_TOPMOST | ExtendedWindowStyles.WS_EX_TOOLWINDOW, trayClassReg, "", WindowStyles.WS_POPUP | WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_CLIPSIBLINGS, 0, 0, GetSystemMetrics(0), (int)(23 * DpiHelper.DpiScale), IntPtr.Zero, IntPtr.Zero, hInstance, IntPtr.Zero); if (HwndTray == IntPtr.Zero) { ShellLogger.Info($"TrayService: Error creating {TrayWndClass} window ({Marshal.GetLastWin32Error()})"); } else { ShellLogger.Debug($"TrayService: Created {TrayWndClass}"); } }
private bool getShowInTaskbar() { // EnumWindows and ShellHook return UWP app windows that are 'cloaked', which should not be visible in the taskbar. if (EnvironmentHelper.IsWindows8OrBetter) { int cbSize = Marshal.SizeOf(typeof(uint)); NativeMethods.DwmGetWindowAttribute(Handle, NativeMethods.DWMWINDOWATTRIBUTE.DWMWA_CLOAKED, out var cloaked, cbSize); if (cloaked > 0) { ShellLogger.Debug($"ApplicationWindow: Cloaked ({cloaked}) window ({Title}) hidden from taskbar"); return(false); } // UWP shell windows that are not cloaked should be hidden from the taskbar, too. StringBuilder cName = new StringBuilder(256); NativeMethods.GetClassName(Handle, cName, cName.Capacity); string className = cName.ToString(); if (className == "ApplicationFrameWindow" || className == "Windows.UI.Core.CoreWindow") { if ((ExtendedWindowStyles & (int)NativeMethods.ExtendedWindowStyles.WS_EX_WINDOWEDGE) == 0) { ShellLogger.Debug($"ApplicationWindow: Hiding UWP non-window {Title}"); return(false); } } else if (!EnvironmentHelper.IsWindows10OrBetter && (className == "ImmersiveBackgroundWindow" || className == "SearchPane" || className == "NativeHWNDHost" || className == "Shell_CharmWindow" || className == "ImmersiveLauncher") && WinFileName.ToLower().Contains("explorer.exe")) { ShellLogger.Debug($"ApplicationWindow: Hiding immersive shell window {Title}"); return(false); } } return(CanAddToTaskbar); }
public void SetOverlayIconDescription(IntPtr lParam) { try { if (ProcId is uint procId) { if (lParam == IntPtr.Zero) { return; } IntPtr hShared = NativeMethods.SHLockShared(lParam, procId); if (hShared == IntPtr.Zero) { return; } string str = Marshal.PtrToStringAuto(hShared); NativeMethods.SHUnlockShared(hShared); OverlayIconDescription = str; } } catch (Exception e) { ShellLogger.Error($"ApplicationWindow: Unable to get overlay icon description from process {Title}: {e.Message}"); } }
private async Task <bool> CheckForUpdate() { try { VersionInfo versionInfo = await httpClient.GetFromJsonAsync <VersionInfo>(_versionUrl); if (Version.TryParse(versionInfo.Version, out Version newVersion)) { if (newVersion > _currentVersion) { return(true); } } else { ShellLogger.Info($"Updater: Unable to parse new version"); } } catch (Exception e) { ShellLogger.Info($"Updater: Unable to check for updates: {e.Message}"); } return(false); }
private void btnBrowse_Click(object sender, RoutedEventArgs e) { try { using (System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog { Description = Localization.DisplayString.sDesktop_BrowseTitle, ShowNewFolderButton = false, SelectedPath = NavigationManager.CurrentItem.Path }) { NativeMethods.SetForegroundWindow(helper.Handle); // bring browse window to front if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (Directory.Exists(fbd.SelectedPath)) { NavigationManager.NavigateTo(fbd.SelectedPath); } } } } catch (Exception exception) { ShellLogger.Warning($"DesktopNavigationToolbar: Exception in FolderBrowserDialog: {exception.Message}"); } }
private void GetParentAndItem() { IParentAndItem pni = _shellItem as IParentAndItem; if (pni == null) { return; } if (pni.GetParentAndItem(out IntPtr parentAbsolutePidl, out IShellFolder parentFolder, out _relativePidl) != NativeMethods.S_OK) { ShellLogger.Error($"ShellItem: Unable to get shell item parent for {Path}"); } if (parentAbsolutePidl != IntPtr.Zero) { Marshal.FreeCoTaskMem(parentAbsolutePidl); } if (parentFolder != null) { // Other ShellItems may reference this IShellFolder so don't set refcount to 0 Marshal.ReleaseComObject(parentFolder); } }
private void btnBrowse_Click(object sender, RoutedEventArgs e) { string filter = "Programs and shortcuts|"; foreach (string ext in AppGrabberService.ExecutableExtensions) { filter += $"*{ext};"; } filter = filter.Substring(0, filter.Length - 2); using (OpenFileDialog dlg = new OpenFileDialog { Filter = filter }) { if (dlg.SafeShowDialog() == System.Windows.Forms.DialogResult.OK && ShellHelper.Exists(dlg.FileName)) { ApplicationInfo customApp = AppGrabberService.PathToApp(dlg.FileName, true, true); if (!ReferenceEquals(customApp, null)) { if (!programsMenuAppsCollection.Contains(customApp) && !(InstalledAppsView.ItemsSource as ObservableCollection <ApplicationInfo>).Contains(customApp)) { programsMenuAppsCollection.Add(customApp); } else { // disallow adding a duplicate ShellLogger.Debug("Excluded duplicate item: " + customApp.Name + ": " + customApp.Target); } } } } }
private string GetDisplayName(SIGDN purpose) { IntPtr hString = IntPtr.Zero; string name = string.Empty; try { if (_shellItem?.GetDisplayName(purpose, out hString) == NativeMethods.S_OK) { if (hString != IntPtr.Zero) { name = Marshal.PtrToStringAuto(hString); } } } catch (Exception e) { ShellLogger.Error($"ShellItem: Unable to get {purpose} display name: {e.Message}"); } finally { Marshal.FreeCoTaskMem(hString); } return(name); }
public SafeNotifyIconData(NOTIFYICONDATA nid) { cbSize = nid.cbSize; hWnd = (IntPtr)nid.hWnd; uID = nid.uID; uFlags = nid.uFlags; uCallbackMessage = nid.uCallbackMessage; try { hIcon = (IntPtr)nid.hIcon; } catch (Exception e) { ShellLogger.Error($"SafeNotifyIconData: Unable to convert icon handle: {e.Message}"); } szTip = nid.szTip; dwState = nid.dwState; dwStateMask = nid.dwStateMask; szInfo = nid.szInfo; uVersion = nid.uVersion; szInfoTitle = nid.szInfoTitle; dwInfoFlags = nid.dwInfoFlags; guidItem = nid.guidItem; hBalloonIcon = nid.hBalloonIcon; }
private IShellItem GetParentShellItem() { IShellItem parent = null; try { if (_shellItem?.GetParent(out parent) != NativeMethods.S_OK) { parent = null; } } catch (Exception e) { ShellLogger.Error($"ShellItem: Unable to get parent shell item: {e.Message}"); // Fall back to the root shell item via empty string try { parent = GetShellItem(string.Empty); } catch (Exception exception) { ShellLogger.Error($"ShellItem: Unable to get fallback parent shell item: {exception.Message}"); } } return(parent); }
public void IconMouseUp(MouseButton button, uint mouse, int doubleClickTime) { ShellLogger.Debug($"NotifyIcon: {button} mouse button clicked: {Title}"); if (button == MouseButton.Left) { if (handleClickOverride(true)) { return; } SendMessage((uint)WM.LBUTTONUP, mouse); // This is documented as version 4, but Explorer does this for version 3 as well if (Version >= 3) { SendMessage((uint)NIN.SELECT, mouse); } _lastLClick = DateTime.Now; } else if (button == MouseButton.Right) { SendMessage((uint)WM.RBUTTONUP, mouse); // This is documented as version 4, but Explorer does this for version 3 as well if (Version >= 3) { SendMessage((uint)WM.CONTEXTMENU, mouse); } _lastRClick = DateTime.Now; } }
private bool haveDisplaysChanged() { resetScreenCache(); if (_screenState.Count == Screen.AllScreens.Length) { bool same = true; for (int i = 0; i < Screen.AllScreens.Length; i++) { Screen current = Screen.AllScreens[i]; if (!(_screenState[i].Bounds == current.Bounds && _screenState[i].DeviceName == current.DeviceName && _screenState[i].Primary == current.Primary)) { same = false; break; } } if (same) { ShellLogger.Debug("WindowManager: No display changes"); return(false); } } return(true); }
protected void AddFavoritesClicked(object sender, ImageClickEventArgs e) { //Thread.Sleep(40000); var currentUserGuid = new Guid(Session["CurrentUser"].ToString()); string[] commandArguents = ((ImageButton)sender).CommandArgument.Split(';'); bool isFavorite = bool.Parse(commandArguents[1]); var favoriteUserGuid = new Guid(commandArguents[0]); SqlConnection connection = DBHelper.GetConnection(); string commandText = isFavorite ? "RemoveFavorites" : "AddFavorites"; var cmd = new SqlCommand(commandText, connection) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.Add("@ParentUserGuid", SqlDbType.UniqueIdentifier); cmd.Parameters["@ParentUserGuid"].Value = currentUserGuid; cmd.Parameters.Add("@FavoriteUserGuid", SqlDbType.UniqueIdentifier); cmd.Parameters["@FavoriteUserGuid"].Value = favoriteUserGuid; try { connection.Open(); cmd.ExecuteNonQuery(); EmployeesListView.DataBind(); } catch (Exception ex) { ShellLogger.WriteLog("DB.log", "Ошибка добаления сотрудника в избранное", ex); } finally { connection.Close(); } }
public static ApplicationInfo PathToApp(string filePath, string fileDisplayName, bool allowNonApps, bool allowExcludedNames) { ApplicationInfo ai = new ApplicationInfo(); string fileExt = Path.GetExtension(filePath); if (allowNonApps || ExecutableExtensions.Contains(fileExt, StringComparer.OrdinalIgnoreCase)) { try { ai.Name = fileDisplayName; ai.Path = filePath; string target; if (fileExt.Equals(".lnk", StringComparison.OrdinalIgnoreCase)) { Link link = new Link(filePath); target = link.Target; } else { target = filePath; } ai.Target = target; // remove items that we can't execute. if (!allowNonApps) { if (!string.IsNullOrEmpty(target) && !ExecutableExtensions.Contains(Path.GetExtension(target), StringComparer.OrdinalIgnoreCase)) { ShellLogger.Debug($"AppGrabberService: Not an app: {filePath}: {target}"); return(null); } // remove things that aren't apps (help, uninstallers, etc) if (!allowExcludedNames) { foreach (string word in excludedNames) { if (ai.Name.ToLower().Contains(word)) { ShellLogger.Debug($"AppGrabberService: Excluded item: {filePath}: {target}"); return(null); } } } } return(ai); } catch (Exception ex) { ShellLogger.Error($"AppGrabberService: Error creating ApplicationInfo object: {ex.Message}"); return(null); } } return(null); }
public static ApplicationInfo PathToApp(string file, bool allowNonApps, bool allowExcludedNames) { ApplicationInfo ai = new ApplicationInfo(); string fileExt = Path.GetExtension(file); if (allowNonApps || ExecutableExtensions.Contains(fileExt, StringComparer.OrdinalIgnoreCase)) { try { ai.Name = ShellHelper.GetDisplayName(file); ai.Path = file; string target = string.Empty; if (fileExt.Equals(".lnk", StringComparison.OrdinalIgnoreCase)) { Shell.Link link = new Shell.Link(file); target = link.Target; } else { target = file; } ai.Target = target; // remove items that we can't execute. if (!allowNonApps) { if (!string.IsNullOrEmpty(target) && !ExecutableExtensions.Contains(Path.GetExtension(target), StringComparer.OrdinalIgnoreCase)) { ShellLogger.Debug("Not an app: " + file + ": " + target); return(null); } // remove things that aren't apps (help, uninstallers, etc) if (!allowExcludedNames) { foreach (string word in excludedNames) { if (ai.Name.ToLower().Contains(word)) { ShellLogger.Debug("Excluded item: " + file + ": " + target); return(null); } } } } return(ai); } catch (Exception ex) { ShellLogger.Error("Error creating ApplicationInfo object in appgrabber. " + ex.Message, ex); return(null); } } return(null); }
internal void Initialize() { if (IsInitialized) { return; } try { ShellLogger.Debug("TasksService: Starting"); // create window to receive task events _HookWin = new NativeWindowEx(); _HookWin.CreateHandle(new CreateParams()); // prevent other shells from working properly SetTaskmanWindow(_HookWin.Handle); // register to receive task events RegisterShellHookWindow(_HookWin.Handle); WM_SHELLHOOKMESSAGE = RegisterWindowMessage("SHELLHOOK"); WM_TASKBARCREATEDMESSAGE = RegisterWindowMessage("TaskbarCreated"); TASKBARBUTTONCREATEDMESSAGE = RegisterWindowMessage("TaskbarButtonCreated"); _HookWin.MessageReceived += ShellWinProc; if (EnvironmentHelper.IsWindows8OrBetter) { // set event hook for uncloak events uncloakEventProc = UncloakEventCallback; if (uncloakEventHook == IntPtr.Zero) { uncloakEventHook = SetWinEventHook( EVENT_OBJECT_UNCLOAKED, EVENT_OBJECT_UNCLOAKED, IntPtr.Zero, uncloakEventProc, 0, 0, WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS); } } // set window for ITaskbarList setTaskbarListHwnd(_HookWin.Handle); // adjust minimize animation SetMinimizedMetrics(); // enumerate windows already opened and set active window getInitialWindows(); IsInitialized = true; } catch (Exception ex) { ShellLogger.Info("TasksService: Unable to start: " + ex.Message); } }
private void SetupLogging() { ShellLogger.Severity = _logSeverity; SetupFileLog(); ShellLogger.Attach(new ConsoleLog()); }
private ImageSource GetDisplayIcon(IconSize size) { ImageSource icon = null; IShellItemImageFactory imageFactory = GetImageFactory(AbsolutePidl); if (imageFactory == null) { icon = IconImageConverter.GetDefaultIcon(); } else { try { int iconPoints = IconHelper.GetSize(size); SIZE imageSize = new SIZE { cx = (int)(iconPoints * DpiHelper.DpiScale), cy = (int)(iconPoints * DpiHelper.DpiScale) }; IntPtr hBitmap = IntPtr.Zero; SIIGBF flags = 0; if (size == IconSize.Small) { // for 16pt icons, thumbnails are too small flags = SIIGBF.ICONONLY; } if (imageFactory?.GetImage(imageSize, flags, out hBitmap) == NativeMethods.S_OK) { if (hBitmap != IntPtr.Zero) { icon = IconImageConverter.GetImageFromHBitmap(hBitmap); } } } catch (Exception e) { ShellLogger.Error($"ShellItem: Unable to get icon from ShellItemImageFactory: {e.Message}"); } finally { Marshal.FinalReleaseComObject(imageFactory); } } if (icon == null) { // Fall back to SHGetFileInfo icon = IconImageConverter.GetImageFromAssociatedIcon(AbsolutePidl, size); } if (icon == null) { icon = IconImageConverter.GetDefaultIcon(); } return(icon); }
private void keyboardListener_OnKeyPressed(object sender, Common.KeyEventArgs e) { if (e.Key == Key.LWin || e.Key == Key.RWin) { ShellLogger.Debug(e.Key.ToString() + " Key Pressed"); ToggleProgramsMenu(); e.Handled = true; } }