我正在尝试使用空中偷看的API。经过大量的挖掘和搜索,我偶然发现了这段代码:
[DllImport("dwmapi.dll", EntryPoint = "#113", SetLastError = true)]
internal static extern uint DwmpActivateLivePreview(uint , uint , uint , uint );但是我不能让它工作..我不知道参数是什么..我尝试了一些API拦截工具,但都不起作用。如何正确调用此接口?
发布于 2012-12-01 08:43:14
我知道这是一个古老的问题,但是,公认的答案缺乏完整性。
下面是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);我花了几个月的时间对大部分很酷的Windows7任务栏API进行逆向工程,这是我发现的一部分。不管你接受与否,这是使用Aero Peek API的正确方式。我的“研究”是在2008年完成的,当时Windows7还处于测试阶段,泄露的预览版本很普遍。对于那些可能会大惊小怪的人来说,这段代码也应该可以在Windows8上运行。下面是一个简单的示例:
InvokeAeroPeek(enterPeekMode, target, caller, pType, new IntPtr(32), 0x3244);这段代码是处理器不可知的,你想怎么编译它就怎么编译,它仍然可以工作。欢迎使用Win32和x64。
发布于 2011-06-24 11:38:32
你能详细说明你正在尝试做什么吗?您是否正在尝试在自己的应用程序中调用peek或支持自定义Aero peek?
如果是后者,您应该参考http://msdn.microsoft.com/en-us/library/ff819048(v=VS.85).aspx和相关文档。
发布于 2015-08-31 11:26:12
我有个坏消息要告诉每个实际使用这个未记录的函数的人。Windows10似乎在末尾添加了额外的参数。这可能意味着在Win7下运行良好的代码在Win10下可能会崩溃,因为调用此函数后堆栈指针将会出错。此外,调用此函数时有可能缺少堆栈参数,这会导致Win10在调用过程中释放错误的指针。
我使用了下面的定义。
typedef HRESULT (__stdcall *DwmpActivateLivePreview)(BOOL peekOn, HWND hPeekWindow, HWND hTopmostWindow, UINT peekType1or3, UINT_PTR newForWin10);我只是在这个新参数中传递了零。在64位Win10下运行64位代码,我能够使用本页其他答案中描述的参数激活Aero Peek。在64位Win10下运行32位代码时,我得到了与在64位Win7下运行32位代码时相同的0x80070018错误。
https://stackoverflow.com/questions/6450223
复制相似问题