Open URL in Internet Explorer using COM automation
From NSIS Wiki
Jump to navigationJump to search
Author: Anders (talk, contrib) |
This code tries to open a url in internet explorer.
!define VARIANT_TRUE -1 ;((VARIANT_BOOL)-1) !define VT_ERROR 10 !define DISP_E_PARAMNOTFOUND 0x80020004 !define CLSCTX_LOCAL_SERVER 0x4 !define CLSID_InternetExplorer {0002DF01-0000-0000-C000-000000000046} !define IID_IWebBrowserApp {0002DF05-0000-0000-C000-000000000046} !define IWebBrowserApp.Navigate ->11(i,i,i,i,i)i !define IWebBrowserApp.put_Visible ->41(&i2)i Function InternetExplorerAuto_OpenURL exch $2 push $0 push $1 System::Call "ole32::CoCreateInstance( \ g '${CLSID_InternetExplorer}', i 0, \ i ${CLSCTX_LOCAL_SERVER}, \ g '${IID_IWebBrowserApp}', *i 0 r0)" ${If} $0 <> 0 System::Call "$0${IWebBrowserApp.put_Visible} (${VARIANT_TRUE}).r1" ${If} $1 = 0 System::Call "*(i ${VT_ERROR},i ${DISP_E_PARAMNOTFOUND},i)i.r1" ;VARIANT System::Call 'Oleaut32::SysAllocString(w "$2")i.r2' System::Call "$0${IWebBrowserApp.Navigate} ($2,$1,$1,$1,$1)" System::Free $1 System::Call 'Oleaut32::SysFreeString(ir2)' ${EndIf} System::Call "$0->2()" ${EndIf} pop $1 pop $0 pop $2 FunctionEnd section push "http://example.com" call InternetExplorerAuto_OpenURL sectionend