110,533
社区成员
发帖
与我相关
我的任务
分享
[DllImport( "user32.dll" )]
private static extern IntPtr FindWindow( string a , string b );
[DllImport( "user32.dll" )]
public static extern bool SetWindowPos(
IntPtr hWnd , // 窗口句柄
IntPtr hWndInsertAfter , // 排列顺序的句柄
int X , // 水平坐标
int Y , // 垂直坐标
int cx , // 宽
int cy , // 高
uint uFlags // 窗口定位标示
);
private void button_Click( object sender , System.Windows.RoutedEventArgs e )
{
//设置主窗体位于顶层
this.Topmost = true;
IntPtr hwnd = FindWindow( null , "Window1" );
bool bl;
if ( hwnd != IntPtr.Zero )
{
bl = SetWindowPos( hwnd , HWND_TOPMOST , 0 , 0 , (int)SystemParameters.PrimaryScreenWidth , (int)SystemParameters.PrimaryScreenHeight , SWP_NOMOVE | SWP_SHOWWINDOW );
}
//开启进程打开exe窗体
System.Diagnostics.Process appProc = new System.Diagnostics.Process( );
appProc.StartInfo.FileName = appPath;
appProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
appProc.StartInfo.CreateNoWindow = false;
appProc.StartInfo.UseShellExecute=true;
appProc.Start( );
hwndHost = FindWindow( null,"Window2" );
SetWindowPos( hwndHost , (IntPtr)( -2 ) , 0 , 0 , 0 , 0 , 64 );
}