8

我正在尝试使用 API 进行航空窥视。经过大量的挖掘和搜索,我偶然发现了这段代码:

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

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

4

4 回答 4

4

我最终自己解决了。我在我的网站上发布了一篇关于此的文章:http: //www.jesconsultancy.nl/tips-and-tricks/aero-apis.html。不幸的是,这是荷兰语,所以这里有点解释:

 [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 进行了一些处理之后,我找到了第三个参数。设置窗体的 TopMost 属性时,窗体有时仍会显示在 aero peek 效果下方。如果将句柄作为第三个参数传递给需要位于 peek 效果之上的表单,并且表单的 TopMost 属性设置为 true,则您的表单将位于 peek 效果之上。

您可以从 Aero Peek 效果中排除窗口。此处对此进行了描述:http: //huddledmasses.org/fun-with-pinvoke-and-aero-peek/

于 2011-06-27T20:28:03.527 回答
4

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

下面是 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);

我花了几个月的时间对大部分酷炫的 Windows 7 任务栏 API 进行逆向工程,这是我发现的一部分。接受或离开,这是使用 Aero Peek API 的正确方法。我的“研究”是在 2008 年完成的,而 Windows 7 仍处于测试阶段,并且泄露的预览版本很普遍。对于那些可能会大吃一惊的人,这段代码也应该在 Windows 8 中工作。下面是一个简单的例子:

InvokeAeroPeek(enterPeekMode, target, caller, pType, new IntPtr(32), 0x3244);

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

于 2012-12-01T00:43:13.513 回答
1

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

如果是后者,您应该参考http://msdn.microsoft.com/en-us/library/ff819048(v=VS.85).aspx和相关文档。

于 2011-06-24T03:38:31.507 回答
1

对于实际使用此未记录功能的每个人,我都有坏消息。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 64bit 下运行 32bit 代码,我在 Win7 64bit 下运行 32bit 代码时收到相同的 0x80070018 错误。

于 2015-08-31T03:26:11.567 回答