以编程方式激活Outlook
|
我有一个需要在用户单击按钮时激活Outlook(如果正在运行)的应用程序。我已经尝试了以下方法,但是它不起作用。
在window类中声明:
[DllImport( \"user32.dll\" )]
private static extern bool SetForegroundWindow( IntPtr hWnd );
[DllImport( \"user32.dll\" )]
private static extern bool ShowWindowAsync( IntPtr hWnd, int nCmdShow );
[DllImport( \"user32.dll\" )]
private static extern bool IsIconic( IntPtr hWnd );
在按钮“ 1”处理程序内:
// Check if Outlook is running
var procs = Process.GetProcessesByName( \"OUTLOOK\" );
if( procs.Length > 0 ) {
// IntPtr hWnd = procs[0].MainWindowHandle; // Always returns zero
IntPtr hWnd = procs[0].Handle;
if( hWnd != IntPtr.Zero ) {
if( IsIconic( hWnd ) ) {
ShowWindowAsync( hWnd, SW_RESTORE );
}
SetForegroundWindow( hWnd );
}
}
无论当前将Outlook最小化到任务栏还是最小化到系统任务栏或最大化,这都不起作用。如何激活Outlook窗口?
没有找到相关结果
已邀请:
4 个回复
降女陷费券
。我也较早尝试过此方法,但它导致现有Outlook窗口的大小发生了调整,这很烦人。秘密是将“ 4”参数传递给Outlook,这指示它重新使用现有窗口。调用看起来像这样:
痰嫉
芜任亮蜡
贡炮逗握惫