2011-09-05 4 views
2

콘솔 응용 프로그램 내에서 Word를 여는 중입니다. Word 응용 프로그램을 표시 한 후에도 콘솔이 활성 창으로 유지되는지 어떻게 확인할 수 있습니까?콘솔 창 활성화

답변

2

당신은 당신이 무엇을 물어 얻을 수있는 SetForegroundWindow API 호출을 사용해야합니다

using System; 
using Microsoft.Office.Interop.Word; 

namespace WordDocumentObject { 
    class Program { 
     static void Main(string[] args) { 
      _Application app = new Application(); 
      app.Visible = true; 

      //Activate the console window here 

      Console.WriteLine("Press any key to continue..."); 
      Console.ReadKey(true); 
     } 
    } 
} 
:

[DllImport("user32.dll")] 
[return: MarshalAs(UnmanagedType.Bool)] 
static extern bool SetForegroundWindow(IntPtr hWnd); 

전체 예제는 SO 이미 :

bring a console window to front in c#

+0

그럴 수 없어 내가 그걸 놓쳤다 고 생각해. –

관련 문제