Autor Tema: Porfavor Ayuda con el WebBrowser  (Leído 3449 veces)

0 Usuarios y 1 Visitante están viendo este tema.

..::Carlos::..

  • Bytes
  • *
  • Mensajes: 44
  • Reputación: +0/-0
    • Ver Perfil
Porfavor Ayuda con el WebBrowser
« en: Agosto 27, 2013, 11:37:04 am »
como puedo hacer para que cuando el control webbrowser me abra una pagina web la abra como si fuera IE9 y no como si fuera IE antiguo
porfa necesito esa ayuda gracias

LeandroA

  • Administrador
  • Petabyte
  • *****
  • Mensajes: 1128
  • Reputación: +151/-8
    • Ver Perfil
Re:Porfavor Ayuda con el WebBrowser
« Respuesta #1 en: Agosto 27, 2013, 02:45:40 pm »
Hola bueno eso es forzar algo que no es, pero puede servir para almenos entrar, la formula es cambiar el User Agent

Ese que use es el de IE9, podes poner cualquier otro, pero ten en cuenta que html5 ni a palos, cualquier cosa pone WebBrowser1.Silent = True
Código: [Seleccionar]
Option Explicit
Private Const URLMON_OPTION_USERAGENT = &H10000001
Private Declare Sub UrlMkSetSessionOption Lib "URLMON.dll" (ByVal dwOption As Long, ByRef pBuffer As Any, ByVal dwBufferLength As Long, ByVal dwReserved As Long)

Private Sub Form_Load()
    Dim UA As String
    UA = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
    Call UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, ByVal UA, Len(UA), 0)
    WebBrowser1.Navigate "http://youruseragent.info/cual-es-mi-user-agent"
End Sub

..::Carlos::..

  • Bytes
  • *
  • Mensajes: 44
  • Reputación: +0/-0
    • Ver Perfil
Re:Porfavor Ayuda con el WebBrowser
« Respuesta #2 en: Agosto 27, 2013, 03:01:14 pm »
Gracias leandro gracias por ayudar deja y veo como me va

LeandroA

  • Administrador
  • Petabyte
  • *****
  • Mensajes: 1128
  • Reputación: +151/-8
    • Ver Perfil
Re:Porfavor Ayuda con el WebBrowser
« Respuesta #3 en: Septiembre 10, 2013, 09:08:15 pm »
Hola Carlos encontre otra forma mas efectiva, que la que te pase, con esta se muestra como la ultima versión del ie instalado, pero compilado, yo comente el ide

Código: [Seleccionar]
Option Explicit

Private Const REG_DWORD = 4
Private Const HKEY_CURRENT_USER = &H80000001

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long

Sub WebBrowser_IE9()
  Dim Ret As Long, RegistryKey As Long
  Dim sBuffer As String
    Ret = RegCreateKey(HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", RegistryKey)
     
   ' sBuffer = Space(255)
   '    Ret = RegQueryValueEx(RegistryKey, "VB6.exe", 0, REG_DWORD, ByVal sBuffer, 255&)
   '     If Ret <> 0 Then RegSetValueEx RegistryKey, "VB6.exe", 0&, REG_DWORD, ByVal CStr(Chr(40) & Chr(35) & Chr(0) & Chr(0)), 4&
     
    sBuffer = Space(255)
      Ret = RegQueryValueEx(RegistryKey, App.EXEName & ".exe", 0, REG_DWORD, ByVal sBuffer, 255&)
        If Ret <> 0 Then RegSetValueEx RegistryKey, App.EXEName & ".exe", 0&, REG_DWORD, ByVal CStr(Chr(0) & Chr(0) & Chr(0) & Chr(0)), 4&
   
    Ret = RegCloseKey(RegistryKey)
End Sub
« última modificación: Septiembre 10, 2013, 09:11:16 pm por LeandroA »