我知道这是一个较老的问题,但是接受的答案缺乏完整性。
下面是 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 都是受欢迎的。