'写入注册表 WebBrowser1设定内核
Private Function SetRegistry(ByVal strKey As String, ByVal strName As String, ByVal strValue As String) As Boolean
Try
Dim Key_LocalMachine As Microsoft.Win32.RegistryKey
Key_LocalMachine = My.Computer.Registry.CurrentUser 'get the key path of HKEY_LOCAL_USER
Dim Key_Created As Microsoft.Win32.RegistryKey
Key_Created = Key_LocalMachine.OpenSubKey(strKey, True) 'set the true for can write
If Key_Created Is Nothing Then
Key_Created = Key_LocalMachine.CreateSubKey(strKey) 'careat the key
End If
Key_Created.SetValue(strName, strValue, Microsoft.Win32.RegistryValueKind.DWord) 'set the values of the key
Return True
Catch ex As Exception
Return False
End Try
End Function
'判断注册表
Private Function RegistryExist(ByVal strKey As String, ByVal strName As String) As Boolean
Try
Dim Key_LocalMachine As Microsoft.Win32.RegistryKey
Key_LocalMachine = My.Computer.Registry.CurrentUser 'get the key path of HKEY_LOCAL_USER
Dim Key_Exist As Microsoft.Win32.RegistryKey
Key_Exist = Key_LocalMachine.OpenSubKey(strKey, True) 'set the true for can write
If Key_Exist Is Nothing Then
Return False
End If
If Key_Exist.GetValue(strName) Is Nothing Then
Return False
End If
Return True
Catch ex As Exception
Return False
End Try
End Function
If RegistryExist("Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", My.Application.Info.AssemblyName & ".exe") = False Then '判断如果注册表 键值不存在
SetRegistry("Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", My.Application.Info.AssemblyName & ".exe", "11001") '写入注册表
End If