Windows aero peek API

发布于 2024-11-16 22:02:08 字数 300 浏览 7 评论 0原文

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

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

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

I am trying to use the API for aero peek. With a lot of digging and searching I stumbled upon this piece of code:

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

But I can't get it to work.. I don't know what the parameters are.. I tried some API intercepting tools but that didn't work out. How can I discover how to properly call this API?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

半枫 2024-11-23 22:02:08

我最终自己解决了这个问题。我在我的网站上发布了一篇关于此的文章:
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 属性时,表单有时仍会显示在航空窥视效果下方。如果将需要位于窥视效果顶部的表单的句柄作为第三个参数传递,并且表单的 TopMost 属性设置为 true,则您的表单将位于窥视效果之上。

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

I eventually solved it my self. I have posted an article on my website about this:
http://www.jesconsultancy.nl/tips-and-tricks/aero-apis.html.
Unfortunately this is in dutch so here is a bit explaining:

 [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

The first parameter is for activating/deactivating the Aero Peek functionality. The second parameter is the handle that Aero peek focuses to. The other two one I haven't been able to identify yet.

Edit:
After some more messing around with this API I figured out the 3th parameter. When setting the TopMost property of a form, the form still shows sometimes underneath of the aero peek effect. If you pass the handle to that form that needs to be on top of the peek effect as the 3th parameter, and the TopMost property of your form is set to true, your form will be on top of the peek effect.

You can exclude a window from the Aero Peek effect. This is described here: http://huddledmasses.org/fun-with-pinvoke-and-aero-peek/

っ〆星空下的拥抱 2024-11-23 22:02:08

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

以下是 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 都受欢迎。

I know this is an older question but, the accepted answer lacks completeness.

Below is the proper usage of the 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);

I spent several months reverse engineering most of the cool Windows 7 taskbar API and this is part of my findings. Take it or leave it, this is the proper way to use the Aero Peek API. My "research" was done in 2008, while Windows 7 was still in beta and leaked preview builds were prevalent. For those that might give a shit, this code should work in Windows 8, too. A simple example follows, below:

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

This code is processor agnostic, compile it however you want and it will still work. Win32 and x64 are both welcome.

策马西风 2024-11-23 22:02:08

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

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

can you elaborate on what you are trying to do? are you trying to invoke peek or support custom Aero peek in your own application?

if the latter you should reference http://msdn.microsoft.com/en-us/library/ff819048(v=VS.85).aspx and related documentation.

故事与诗 2024-11-23 22:02:08

对于实际使用这个未记录功能的每个人来说,我有一个坏消息。 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错误。

I have bad news for everyone actually using this undocumented function. Windows 10 appears to have added an extra argument to the end. This likely means your code that run fine under Win7 will probably crash under Win10 because the stack pointer is going to screwed up after you call this function. Plus, there is a chance that calling this function with a missing stack argument will cause Win10 to deref a bad pointer during the call itself.

I used the following definition.

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

I simply passed zero in this new argument. Running 64bit code under Win10 64bit, I was able to activate Aero Peek using arguments as described in the other answers on this page. Running 32bit code under Win10 64bit, I got the same 0x80070018 error I received when running 32bit code under Win7 64bit.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文