Skip to content

Instantly share code, notes, and snippets.

@kumatti1
Created April 12, 2015 22:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumatti1/80d80d2a91cfe5e72246 to your computer and use it in GitHub Desktop.
Save kumatti1/80d80d2a91cfe5e72246 to your computer and use it in GitHub Desktop.
IE11対策
Option Explicit
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
'https://msdn.microsoft.com/en-us/library/52e6es3z.aspx
Private Declare PtrSafe _
Function AtlComQIPtrAssign Lib "atl110.dll" ( _
ByRef pp As IUnknown, _
ByVal lp As IUnknown, _
ByRef riid As GUID _
) As IUnknown
Private Declare PtrSafe _
Function IIDFromString Lib "ole32.dll" ( _
ByVal lpsz As LongPtr, _
ByRef lpiid As GUID _
) As Long
Sub hoge()
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate "https://www.google.co.jp/?gws_rd=ssl"
While ie.busy Or ie.ReadyState <> 4
DoEvents
Wend
Dim pElement As Object
Set pElement = ie.document.forms("f")("q")
Dim IID_IHTMLElement2 As GUID
Dim hr As Long
hr = IIDFromString(StrPtr("{3050F434-98B5-11CF-BB82-00AA00BDCE0B}"), IID_IHTMLElement2)
Debug.Print Hex$(hr)
Dim unk As IUnknown
Dim tmp As IUnknown
Set tmp = AtlComQIPtrAssign(unk, pElement, IID_IHTMLElement2)
Debug.Print unk Is Nothing, tmp Is Nothing
If tmp Is unk Then
MsgBox "同じやん(・∀・)"
End If
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment