我正在尝试使用该API的航空偷看。 随着大量的挖掘和search,我偶然发现了这段代码:
[DllImport("dwmapi.dll", EntryPoint = "#113", SetLastError = true)] internal static extern uint DwmpActivateLivePreview(uint , uint , uint , uint );
但我不能得到它的工作..我不知道什么参数是..我尝试了一些API拦截工具,但没有奏效。 我怎样才能发现如何正确调用这个API?
我最终解决了我的自我。 我已经在我的网站上发布了一篇文章: 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效果的下面。 如果您将句柄传递给需要位于第三个参数的顶层效果之上的表单,并且表单的TopMost属性设置为true,则您的表单将处于peek效果之上。
您可以从Aero Peek效果中排除一个窗口。 这在这里描述: http : //huddledmasses.org/fun-with-pinvoke-and-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);
我花了好几个月的时间对大多数酷炫的Windows 7任务栏API进行逆向工程,这是我发现的一部分。 拿走或离开,这是使用Aero Peek API的正确方法。 我的“研究”是在2008年完成的,而Windows 7仍处于测试阶段,泄露的预览版本普遍存在。 对于那些可能会给狗屎,这个代码也应该在Windows 8中工作。 下面是一个简单的例子:
InvokeAeroPeek(enterPeekMode, target, caller, pType, new IntPtr(32), 0x3244);
这个代码是处理器不可知的,不管你想要编译它,它仍然可以工作。 Win32和x64都是受欢迎的。
你能详细说明你在做什么吗? 你是否试图在你自己的应用程序中调用偷看或支持自定义的Aero偷看?
如果后者您应该引用http://msdn.microsoft.com/en-us/library/ff819048(v=VS.85).aspx和相关文档。
对于每个使用这个无证函数的人,我都有一个坏消息。 Windows 10似乎在最后添加了一个额外的参数。 这可能意味着在Win7下运行良好的代码可能会在Win10下崩溃,因为在你调用这个函数之后堆栈指针会被搞砸了。 此外,有一个机会,调用这个函数与一个缺少堆栈参数将导致Win10在调用本身deref一个坏的指针。
我用了下面的定义。
typedef HRESULT (__stdcall *DwmpActivateLivePreview)(BOOL peekOn, HWND hPeekWindow, HWND hTopmostWindow, UINT peekType1or3, UINT_PTR newForWin10);
我只是在这个新的论点中通过零。 在Win10 64bit下运行64位代码,我可以使用本页其他答案中所述的参数激活Aero Peek。 在Win10 64bit下运行32位代码,得到了我在Win7 64位下运行32位代码时收到的0x80070018错误。