SHDocVw를 이용해 InternetExplorer객체를 이용해보는 프로젝트를 하려고 하는데 당최 찾을 수가 없었다 알고보니 미리 참조가 되어있지 않았던 탓

C:\Windows\System32\shdocvw.dll를 참조하기위해 프로젝트의 참조 부분에 Microsoft Internet control을 추가 해주면 된다.

참조에서 마우스 우클릭후 참조추가 >COM>Microsoft Internet Controls 체크 후 확인

 

자 이제 사용하면된다.

 

간단한 예제

 

    SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer();
    ie.Visible = true;
    ie.Navigate("http://naver.com/");

 

이렇게 하면 네이버에 접속된 익스플로러 새창이 뜬다.

 

---------------------------------------------------------------------------------

참고로 메서드위에 DllImport를 이용하면 참조하지 않고 사용이 된다고 한다.

대신 static extern으로 이용가능

 

using System.Runtime.InteropServices;

[DllImport("C:\\Windows\\System32\\shdocvw.dll")]

 private(public) static extern 데이터타입 함수명(파라미터);

'Programing > C#' 카테고리의 다른 글

[C#] mshtml 사용하기  (0) 2015.06.22
Posted by duehd88
,