Exemple #1
0
        /// <summary>
        /// Initializes the current state.
        /// </summary>
        public void Init()
        {
            try
            {
                // Try to find the Hwnd for the current console. If we can't find it, we'll just silently ignore and not provide a progress bar.
                m_consoleHwnd = NativeMethods.GetConsoleWindow();
                if (m_consoleHwnd == IntPtr.Zero)
                {
                    return;
                }

                m_taskbarList = (NativeMethods.ITaskbarList3)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid(TaskBarListClsId)));
#pragma warning disable RS0015 // Always consume the value returned by methods marked with PreserveSigAttribute
                m_taskbarList.HrInit();
#pragma warning restore RS0015 // Always consume the value returned by methods marked with PreserveSigAttribute
            }
            catch (Exception)
            {
            }
        }
Exemple #2
0
 private static void Init()
 {
     lock (_syncRoot) {
         try {
             if (_taskbarList == null)
             {
                 _taskbarList = (NativeMethods.ITaskbarList3) new NativeMethods.CTaskbarList();
                 var res = _taskbarList.HrInit();
                 if (res != NativeMethods.S_OK)
                 {
                     throw new Win32Exception(string.Format(CultureInfo.InvariantCulture, "Native error {0:x8}.", res));
                 }
             }
         } catch (NotImplementedException) {
             _taskbarList = null;
             if (DoNotThrowNotImplementedException == false)
             {
                 throw;
             }
         }
     }
 }
 private TaskbarHelper()
 {
     taskbar = (NativeMethods.ITaskbarList3) new TaskbarInstance();
     taskbar.HrInit();
 }
 private static void Init()
 {
     lock (_syncRoot) {
         try {
             if (_taskbarList == null) {
                 _taskbarList = (NativeMethods.ITaskbarList3)new NativeMethods.CTaskbarList();
                 var res = _taskbarList.HrInit();
                 if (res != NativeMethods.S_OK) { throw new Win32Exception(string.Format(CultureInfo.InvariantCulture, "Native error {0:x8}.", res)); }
             }
         } catch (NotImplementedException) {
             _taskbarList = null;
             if (DoNotThrowNotImplementedException == false) { throw; }
         }
     }
 }