C# 에서 Webbrowser 를 이용할 때 기본적으로 IE 7 버전으로 적용되어 있습니다.


Webbrowser 버전은 아래와 같이 변경 가능합니다.


버전 변경을 위해선 레지스트리를 수정해줘야합니다.


64BIT

\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\

32BIT

\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\

폴더 내에 REG_DWORD 타입, 프로세스명의 레지스트리를 생성해주면 됩니다.

아래 능숙한 그림판 스킬로 제작한 캡처화면과 함께 보시죠.


아래는 데이터 밸류 입니다.

value

Description

10001 (0x2711)

Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.

10000 (0x02710)Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for Internet Explorer 10.
9999 (0x270F)Windows Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.
9000 (0x2328)Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.
8888 (0x22B8)Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive.
8000 (0x1F40)Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for Internet Explorer 8
7000 (0x1B58)Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control.


이걸 C#에서는 어떻게  사용할 수 있을까요?


Microsoft.Win32.Registry 클래스 내부에  SetValue를 이용하여 아래와 같이 사용하실 수 있습니다.


if (Environment.Is64BitOperatingSystem) // 운영체제 종류 확인 (64비트)

{

Microsoft.Win32.Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", Application.ProductName + ".exe", 11001);

Microsoft.Win32.Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", Application.ProductName + ".vshost.exe", 11001);

}

else

{  //For 32 bit machine

Microsoft.Win32.Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", Application.ProductName + ".exe", 11001);

Microsoft.Win32.Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", Application.ProductName + ".vshost.exe", 11001);

}


저의 경우에는 디버깅 시에도 브라우저 변경이 필요해서 vshost도 추가하였습니다.


아래는 SetValue 정의입니다.


아, 레지스트리를 변경하려면 관리자 권한이 필요합니다.

프로그램 실행 시 관리자 권한을 얻기 위해서는 아래와 같이 할 수 있습니다.


솔루션 탐색기에서 프로젝트를 오른쪽 마우스로 클릭하여 속성으로 들어갑니다.



보안 탭에서 ClickOnce 보안 설정 사용 을 체크합니다.


체크를 하면 솔루션 탐색기에 아래와 같이 새로운 파일이 보이게 됩니다.

체크를 다시 해제해도 아래의 파일은 남아있습니다. 체크 해제 꾹



app.mainfeest 파일을 열어 requestedExecutionLevel 의 level 이 기본 asInvoker 로 되어 있는 것을 확인하실 수 있습니다.

level을 변경해주십ㄴ다.

주석창에 나와있듯이 requireAdministrator로 변경!

끝!


+ Recent posts