/// <summary>
        /// Returns the desktop id for a window.
        /// </summary>
        /// <param name="hWindow">Handle of the window.</param>
        /// <param name="desktopId">The guid of the desktop, where the window is shown.</param>
        /// <returns>HResult of the called method as integer.</returns>
        public int GetWindowDesktopId(IntPtr hWindow, out Guid desktopId)
        {
            if (_virtualDesktopManager == null)
            {
                Log.Error("VirtualDesktopHelper.GetWindowDesktopId() failed: The instance of <IVirtualDesktopHelper> isn't available.", typeof(VirtualDesktopHelper));
                desktopId = Guid.Empty;
                return(unchecked ((int)HRESULT.E_UNEXPECTED));
            }

            return(_virtualDesktopManager.GetWindowDesktopId(hWindow, out desktopId));
        }
예제 #2
0
        public Guid GetWindowDesktopId(IntPtr TopLevelWindow)
        {
            Guid result;
            int  hr;

            if ((hr = manager.GetWindowDesktopId(TopLevelWindow, out result)) != 0)
            {
                Marshal.ThrowExceptionForHR(hr);
            }
            return(result);
        }
예제 #3
0
        public async Task <Guid> GetWindowDesktopId(IntPtr TopLevelWindow)
        {
            return(await Window.Dispatch <Guid>(() =>
            {
                Guid result;
                int hr;
                if ((hr = manager.GetWindowDesktopId(TopLevelWindow, out result)) != 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }

                return result;
            }));
        }