첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

▶ WebBrowser 클래스 : Internet Explorer 버전 11 사용하기 예제

using System.Diagnostics;

string applicationFileName = $"{Process.GetCurrentProcess().ProcessName}.exe";

SetRegistryKeyForWebBrowserControl(applicationFileName);

 

※ 관리자 권한으로 실행해야 한다.

 

728x90

 

▶ WebBrowser 클래스 : Internet Explorer 버전 11 사용하기

using Microsoft.Win32;
using System;

#region 웹 브라우저 컨트롤용 레지스트 키 설정하기 - SetRegistryKeyForWebBrowserControl(applicationFileName)

/// <summary>
/// 웹 브라우저 컨트롤용 레지스트 키 설정하기
/// </summary>
/// <param name="applicationFileName">애플리케이션 파일명</param>
/// <returns>처리 결과</returns>
/// <remarks>WebBrowser 컨트롤을 Internet Explorer 11 버전으로 동작하도록 해준다.</remarks>
public bool SetRegistryKeyForWebBrowserControl(string applicationFileName)
{
    RegistryKey registryKey = null;

    try
    {
        registryKey = Registry.LocalMachine.OpenSubKey
        (
            @"SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION",
            true
        );

        if(registryKey == null)
        {
            return false;
        }

        string registryKeyValue = Convert.ToString(registryKey.GetValue(applicationFileName));

        if(registryKeyValue == "11001")
        {
            registryKey.Close();

            return true;
        }

        if(string.IsNullOrEmpty(registryKeyValue))
        {
            registryKey.SetValue(applicationFileName, unchecked((int)0x2AF9), RegistryValueKind.DWord);
        }

        registryKeyValue = Convert.ToString(registryKey.GetValue(applicationFileName));

        if(registryKeyValue == "11001")
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    catch(Exception)
    {
        return false;
    }
    finally
    {
        if(registryKey != null)
        {
            registryKey.Close();
        }
    }
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요