Windows aero peek API

Windows aero peek API,windows,api,aero,aero-peek,Windows,Api,Aero,Aero Peek,我正在尝试将API用于aero peek。经过大量的挖掘和搜索,我偶然发现了这段代码: [DllImport("dwmapi.dll", EntryPoint = "#113", SetLastError = true)] internal static extern uint DwmpActivateLivePreview(uint , uint , uint , uint ); 但是我不能让它工作。。我不知道参数是什么。。我尝试了一些API拦截工具,但没有成功。我如何发现如

我正在尝试将API用于aero peek。经过大量的挖掘和搜索,我偶然发现了这段代码:

    [DllImport("dwmapi.dll", EntryPoint = "#113", SetLastError = true)]
    internal static extern uint DwmpActivateLivePreview(uint , uint , uint , uint );

但是我不能让它工作。。我不知道参数是什么。。我尝试了一些API拦截工具,但没有成功。我如何发现如何正确调用此API?

您能详细说明您正在尝试做什么吗?您是否试图在自己的应用程序中调用peek或支持自定义Aero peek


如果是后者,您应该参考相关文档。

我最终自己解决了它。我已在我的网站上发布了一篇关于此的文章: . 不幸的是,这是荷兰语,所以这里有一点解释:

 [DllImport("dwmapi.dll", EntryPoint = "#113", SetLastError = true)]
 internal static extern uint DwmpActivateLivePreview(uint switch, IntPtr hWnd, IntPtr c, uint d);

 DwmpActivateLivePreview(1, Handle, topmostWindowHandle, 1);//activate
 DwmpActivateLivePreview(0, Handle, topmostWindowHandle, 1);//deactivate
第一个参数用于激活/停用Aero Peek功能。第二个参数是Aero peek关注的句柄。另外两个我还不能确定

编辑: 在对这个API进行了更多的修改之后,我找到了第三个参数。设置窗体的最顶端属性时,窗体有时仍显示aero peek效果的下方。如果将需要位于peek效果顶部的窗体的句柄作为第三个参数传递,并且窗体的最顶部属性设置为true,则窗体将位于peek效果顶部


可以从Aero Peek效果中排除窗口。这里描述了这一点:

我知道这是一个较老的问题,但公认的答案缺乏完整性

以下是Aero Peek API的正确用法

    ///<summary>
    /// These flags are used in conjunction with the Aero Peek API.
    /// </summary>
    public enum PeekTypes : long
    {
        /// <summary>
        /// This flag is here only for completeness and is not used
        /// </summary>
        NotUsed = 0,
        /// <summary>
        /// Denotes that the Peek API is to operate on the desktop
        /// </summary>
        Desktop = 1,
        /// <summary>
        /// Denotes that the Peek API is to operate on a window.
        /// </summary>
        Window = 3
    }

    /// <summary>
    /// This is the *Almighty* Aero Peek API!
    /// </summary>
    /// <param name="EM">True if we're going into peek mode; False if we're coming out of it.</param>
    /// <param name="PH">The handle of the window we want to put into peek mode; 
    /// IntPtr.Zero if we're coming out of peek mode or peeking on the desktop.</param>
    /// <param name="C">The handle of the window calling the API method.</param>
    /// <param name="pT">One of the <see cref="PeekTypes"/> enum members. 
    /// Pass <see cref="PeekTypes.Desktop"/> if you want to peek on the desktop and <see cref="PeekTypes.Window"/> if you want to peek on a window. <see cref="PeekTypes.None"/> is unused but, there for completeness.</param>
    /// <param name="hPN0">When going into or out of peek mode, always pass new IntPtr(32) for this parameter.</param>
    /// <param name="iFI0">When going into or out of peek mode, always pass 0x3244 for this parameter.</param>
    /// <returns></returns>
    [DllImport("dwmapi.dll", EntryPoint = "#113", CharSet = CharSet.Auto, PreserveSig = true, SetLastError = true, CallingConvention = CallingConvention.StdCall)]
    static extern int InvokeAeroPeek(bool EM, IntPtr PH, IntPtr C, PeekTypes pT, IntPtr hPN0, int x3244);

这段代码与处理器无关,您可以根据需要编译它,它仍然可以工作。Win32和x64都很受欢迎。

我有一个坏消息告诉所有实际使用此未记录函数的人。Windows 10似乎在末尾添加了一个额外的参数。这可能意味着在Win7下运行良好的代码在Win10下可能会崩溃,因为调用此函数后堆栈指针将出错。另外,如果调用此函数时缺少堆栈参数,可能会导致Win10在调用过程中取消对错误指针的引用

我使用了以下定义

typedef HRESULT (__stdcall *DwmpActivateLivePreview)(BOOL peekOn, HWND hPeekWindow, HWND hTopmostWindow, UINT peekType1or3, UINT_PTR newForWin10);

在这个新论点中,我只是通过了零。在Win10 64位下运行64位代码,我能够使用本页其他答案中描述的参数激活Aero Peek。在Win10 64位下运行32位代码时,我遇到了与在Win7 64位下运行32位代码时相同的0x80070018错误。

我试图使用此API“窥视”桌面和其他窗口。就像你在W7中浏览任务栏右角的“show desktop”(显示桌面)按钮一样。不幸的是,在这种情况下,我不能提供任何建议,除了:抱歉,响应太晚。。确保为AnyCPU编译,在x64系统下为x86编译时,API调用将无法工作。在win 7和win 8 dev prev下测试。刚刚在发布的win 8上测试了API,其签名仍然正确。API在Win10中已更改(额外参数)-请参阅本页其他地方的我的答案。答案中的函数定义不正确。IDA Pro显示只有4个参数,而不是6个。请参阅此处了解IDA中的堆栈变量:我没有使用IDA。艾达没有给我看我需要看的东西。这是正确的定义。我应该补充一点,这段代码正在一个主要的、商业化的、多显示器任务栏应用程序中使用,每天有1000人使用。这可能是,但我深入到了这个函数的原始反汇编,并使用IDA Pro进行了反向工程。这里没有6个参数。另外,你的定义用于商业产品这一事实证明不了什么。我们现在在StackOverflow上,在这里我们证实了我们所说的。我想签名allready在8.1下发生了变化。我在某处有正确的签名。。我回家后会去查的。对我来说,这只有在我为x64而不是任何CPU编译时才有效。此外,即使我通过了HTOPMOST窗口,并且我的表单为topmost=True,我也无法使我的应用程序的表单保持最顶端。为了澄清我运行的是Windows 10 x64,我正在使用WPF
typedef HRESULT (__stdcall *DwmpActivateLivePreview)(BOOL peekOn, HWND hPeekWindow, HWND hTopmostWindow, UINT peekType1or3, UINT_PTR newForWin10);