当您调用时FlashWindowEx
,只需传递您要刷新的其他应用程序的 MainWindowHandle。例如,您可以使用FlashOtherWindow
如下所示的函数,传入句柄。
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
[StructLayout(LayoutKind.Sequential)]
public struct FLASHWINFO
{
public UInt32 cbSize;
public IntPtr hwnd;
public UInt32 dwFlags;
public UInt32 uCount;
public UInt32 dwTimeout;
}
internal static void FlashOtherWindow(IntPtr windowHandle)
{
FLASHWINFO fInfo = new FLASHWINFO();
fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));
fInfo.dwFlags = 2;
fInfo.dwTimeout = 0;
fInfo.hwnd = windowHandle;
fInfo.uCount = 3;
FlashWindowEx(ref fInfo);
}
internal static void FlashApplicationWindow(string application)
{
foreach (Process process in Process.GetProcessesByName(application))
FlashOtherWindow(process.MainWindowHandle);
}
我还包括FlashApplicationWindow
了应用程序的名称。你可以像这样使用它:
FlashApplicationWindow("firefox");