Skip to content

Instantly share code, notes, and snippets.

@kumatti1
Created March 26, 2017 22:45
Show Gist options
  • Save kumatti1/c19e64430f69e2374150073d7635f7e6 to your computer and use it in GitHub Desktop.
Save kumatti1/c19e64430f69e2374150073d7635f7e6 to your computer and use it in GitHub Desktop.
0x80004005
Option Explicit
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
Const IID_IDownloadManager = "{988934A4-064B-11D3-BB80-00104B35E7F9}"
Private Declare PtrSafe _
Function IIDFromString Lib "ole32.dll" ( _
ByVal lpsz As LongPtr, _
ByRef lpiid As GUID _
) As Long
Private Declare PtrSafe _
Function IUnknown_QueryService Lib "shlwapi.dll" ( _
ByVal punk As IUnknown, _
ByRef guidService As GUID, _
ByRef riid As GUID, _
ByRef ppvOut As Any _
) As Long
Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Const url = "https://www.google.co.jp/"
Sub hoge()
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate url
While ie.busy Or ie.ReadyState <> 4
Sleep 1&
Wend
Dim hr&, iid As GUID
hr = IIDFromString(StrPtr(IID_IDownloadManager), iid)
Debug.Print Hex$(hr)
Dim unk As IUnknown
hr = IUnknown_QueryService(ie, iid, iid, unk)
Debug.Print Hex$(hr)
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment