Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

854 lines
21 KiB

  1. /*----------------------------------------------------------------------------
  2. isignole.cpp
  3. Contains the functions that control IE OLE Automation for ISIGN32
  4. Copyright (C) 1995-96 Microsoft Corporation
  5. All right reserved
  6. Authors:
  7. jmazner Jeremy Mazner
  8. History:
  9. 9/27/96 jmazner Created. Most of this code is stolen from josephh's CONNECT.EXE
  10. source code at \\josephh8\connect\sink.cpp.
  11. He in turn stole most of the code from examples in Brockshmidt's
  12. "Inside OLE, 2nd edition"
  13. Comments from CDExplorerEvents functions are from josephh
  14. ----------------------------------------------------------------------------*/
  15. #include "isignup.h"
  16. #ifdef WIN32
  17. #define INITGUID
  18. #include "isignole.h"
  19. // 4-29-97 ChrisK Olympus 131
  20. #include <urlmon.h>
  21. EXTERN_C const GUID DIID_DWebBrowserEvents;
  22. EXTERN_C const GUID IID_IWebBrowserApp;
  23. #endif
  24. extern INET_FILETYPE GetInetFileType(LPCTSTR lpszFile);
  25. extern IWebBrowserApp FAR * g_iwbapp;
  26. extern CDExplorerEvents * g_pMySink;
  27. extern IConnectionPoint *g_pCP;
  28. extern TCHAR g_szISPPath[MAX_URL + 1];
  29. extern BOOL CreateSecurityPatchBackup( void );
  30. /*****************************************************
  31. **
  32. ** Function: CDExplorerEvents::CDExplorerEvents
  33. **
  34. ** Description: Constructor for CDExplorerEvents
  35. **
  36. ** Because we stole this code from a sample app, we
  37. ** need to decide if we should do reference counts.
  38. ** It works ok without it in simple senerios, but
  39. ** we should probably research this area, and update
  40. ** the code to handle this properly.
  41. **
  42. ** Parameters:
  43. **
  44. **
  45. ** Returns: Not
  46. **
  47. **
  48. ******************************************************/
  49. CDExplorerEvents::CDExplorerEvents( void )
  50. {
  51. DebugOut("CDExplorerEvents:: constructor.\n");
  52. m_cRef=0;
  53. m_dwCookie=0;
  54. return;
  55. }
  56. /*****************************************************
  57. **
  58. ** Function: CDExplorerEvents::~CDExplorerEvents
  59. **
  60. ** Description: Destructor for CDExplorerEvents
  61. **
  62. ** Parameters: Not
  63. **
  64. ** Returns: Not
  65. **
  66. **
  67. ******************************************************/
  68. CDExplorerEvents::~CDExplorerEvents(void)
  69. {
  70. DebugOut("CDExplorerEvents:: destructor.\n");
  71. return;
  72. }
  73. /*****************************************************
  74. **
  75. ** Function: CDExplorerEvents::QueryInterface
  76. **
  77. ** Description: Is called to QueryInterface for DExplorerEvents.
  78. **
  79. ** Parameters:
  80. **
  81. ** REFIID riid, //Reference ID
  82. ** LPVOID FAR* ppvObj //Pointer to this object
  83. **
  84. ** Returns:
  85. ** S_OK if interface supported
  86. ** E_NOINTERFACE if not
  87. **
  88. ******************************************************/
  89. STDMETHODIMP CDExplorerEvents::QueryInterface (
  90. REFIID riid, //Reference ID
  91. LPVOID FAR* ppvObj //Pointer to this object
  92. )
  93. {
  94. if (IsEqualIID(riid, IID_IDispatch)
  95. )
  96. {
  97. *ppvObj = (DWebBrowserEvents *)this;
  98. AddRef();
  99. DebugOut("CDExplorerEvents::QueryInterface IID_IDispatch returned S_OK\r\n");
  100. return S_OK;
  101. }
  102. if (
  103. IsEqualIID(riid, DIID_DWebBrowserEvents)
  104. )
  105. {
  106. *ppvObj = (DWebBrowserEvents *)this;
  107. AddRef();
  108. DebugOut("CDExplorerEvents::QueryInterface DIID_DExplorerEvents returned S_OK\r\n");
  109. return S_OK;
  110. }
  111. if (
  112. IsEqualIID(riid, IID_IUnknown)
  113. )
  114. {
  115. *ppvObj = (DWebBrowserEvents *)this;
  116. AddRef();
  117. DebugOut("CDExplorerEvents::QueryInterface IID_IUnknown returned S_OK\r\n");
  118. return S_OK;
  119. }
  120. DebugOut("CDExplorerEvents::QueryInterface returned E_NOINTERFACE\r\n");
  121. return E_NOINTERFACE;
  122. }
  123. /*****************************************************
  124. **
  125. ** Function: CDExplorerEvents::AddRef
  126. **
  127. ** Description: Increments the Reference Count for this
  128. ** object.
  129. **
  130. ** Parameters: Not
  131. **
  132. ** Returns: New Reference Count
  133. **
  134. ******************************************************/
  135. STDMETHODIMP_(ULONG) CDExplorerEvents::AddRef(void)
  136. {
  137. DebugOut("CDExplorerEvents:: AddRef.\n");
  138. return ++m_cRef;
  139. }
  140. /*****************************************************
  141. **
  142. ** Function: CDExplorerEvents::Release
  143. **
  144. ** Description: Decrements the reference count, frees
  145. ** the object if zero.
  146. **
  147. ** Parameters: not
  148. **
  149. ** Returns: decremented reference count
  150. **
  151. ******************************************************/
  152. STDMETHODIMP_(ULONG) CDExplorerEvents::Release(void)
  153. {
  154. DebugOut("CDExplorerEvents:: Release.\n");
  155. if (0!=--m_cRef)
  156. return m_cRef;
  157. delete this;
  158. return 0;
  159. }
  160. /*****************************************************
  161. **
  162. ** Function: CDExplorerEvents::GetTypeInfoCount
  163. **
  164. ** Description: GetTypeInfoCount is required, but STUBBED
  165. **
  166. ** Parameters: Not used
  167. **
  168. ** Returns: E_NOTIMPL
  169. **
  170. ******************************************************/
  171. STDMETHODIMP CDExplorerEvents::GetTypeInfoCount (UINT FAR* pctinfo)
  172. {
  173. return E_NOTIMPL;
  174. }
  175. /*****************************************************
  176. **
  177. ** Function: CDExplorerEvents::GetTypeInfo
  178. **
  179. ** Description: GetTypeInfo is required, but STUBBED
  180. **
  181. ** Parameters: Not used
  182. **
  183. ** Returns: E_NOTIMPL
  184. **
  185. ******************************************************/
  186. STDMETHODIMP CDExplorerEvents::GetTypeInfo(UINT itinfo,LCID lcid,ITypeInfo FAR* FAR* pptinfo)
  187. {
  188. return E_NOTIMPL;
  189. }
  190. /*****************************************************
  191. **
  192. ** Function: CDExplorerEvents::GetIDsOfNames
  193. **
  194. ** Description: GetIDsOfNames is required, but STUBBED
  195. **
  196. ** Parameters: Not used
  197. **
  198. ** Returns: E_NOTIMPL
  199. **
  200. ******************************************************/
  201. STDMETHODIMP CDExplorerEvents::GetIDsOfNames (REFIID riid,OLECHAR FAR* FAR* rgszNames,UINT cNames,
  202. LCID lcid, DISPID FAR* rgdispid)
  203. {
  204. return E_NOTIMPL;
  205. }
  206. /*****************************************************
  207. **
  208. ** Function: CDExplorerEvents::Invoke
  209. **
  210. ** Description: This is the callback for our IE event sink.
  211. **
  212. ** jmazner -- we only handle two events:
  213. ** BEFORENAVIGATE: check whether the UEL is an .isp file.
  214. ** if so, cancel the navigation and signal processISP
  215. ** Otherwise, allow the navigation to continue
  216. ** (note that this means .ins files are handled by IE
  217. ** execing another instance of isignup)
  218. ** QUIT: we want to release our hold on IWebBrowserApp; if we send the quit
  219. ** ourselves, this is actually done in KillOle, but if IE quits of
  220. ** its own accord, we have to handle it here.
  221. **
  222. ** Parameters: Many
  223. **
  224. ** Returns: S_OK
  225. **
  226. ******************************************************/
  227. STDMETHODIMP CDExplorerEvents::Invoke (
  228. DISPID dispidMember,
  229. REFIID riid,
  230. LCID lcid,
  231. WORD wFlags,
  232. DISPPARAMS FAR* pdispparams,
  233. VARIANT FAR* pvarResult,
  234. EXCEPINFO FAR* pexcepinfo,
  235. UINT FAR* puArgErr
  236. )
  237. {
  238. INET_FILETYPE fileType;
  239. DWORD dwresult;
  240. HRESULT hresult;
  241. DWORD szMultiByteLength;
  242. TCHAR *szTheURL = NULL;
  243. static fAlreadyBackedUpSecurity = FALSE;
  244. switch (dispidMember)
  245. {
  246. case DISPID_BEFORENAVIGATE:
  247. DebugOut("CDExplorerEvents::Invoke (DISPID_NAVIGATEBEGIN) called\r\n");
  248. //Assert( pdispparams->cArgs == 6 )
  249. //TODO UNDONE what's the right way to figure out which arg is which???
  250. #ifndef UNICODE
  251. szMultiByteLength = WideCharToMultiByte(
  252. CP_ACP,
  253. NULL,
  254. pdispparams->rgvarg[5].bstrVal, // first arg is URL
  255. -1, //NUll terminated? I hope so!
  256. NULL, //tell us how long the string needs to be
  257. 0,
  258. NULL,
  259. NULL);
  260. if( 0 == szMultiByteLength )
  261. {
  262. DebugOut("ISIGNUP: CDExplorerEvents::Invoke couldn't determine ASCII URL length\r\n");
  263. dwresult = GetLastError();
  264. hresult = HRESULT_FROM_WIN32( dwresult );
  265. return( hresult );
  266. }
  267. szTheURL = (CHAR *) GlobalAlloc( GPTR, sizeof(CHAR) * szMultiByteLength );
  268. if( !szTheURL )
  269. {
  270. DebugOut("ISIGNUP: CDExplorerEvents::Invoke couldn't allocate szTheURL\r\n");
  271. hresult = HRESULT_FROM_WIN32( ERROR_OUTOFMEMORY );
  272. return( hresult );
  273. }
  274. dwresult = WideCharToMultiByte(
  275. CP_ACP,
  276. NULL,
  277. pdispparams->rgvarg[5].bstrVal, // first arg is URL
  278. -1, //NUll terminated? I hope so!
  279. szTheURL,
  280. szMultiByteLength,
  281. NULL,
  282. NULL);
  283. if( 0 == dwresult )
  284. {
  285. DebugOut("ISIGNUP: CDExplorerEvents::Invoke WideCharToMultiByte failed\r\n");
  286. dwresult = GetLastError();
  287. hresult = HRESULT_FROM_WIN32( dwresult );
  288. return( hresult );
  289. }
  290. #else // UNICODE
  291. szTheURL = (TCHAR *) GlobalAlloc( GPTR, sizeof(TCHAR) * (lstrlen(pdispparams->rgvarg[5].bstrVal)+1) );
  292. if (!szTheURL)
  293. {
  294. hresult = HRESULT_FROM_WIN32( ERROR_OUTOFMEMORY );
  295. return( hresult );
  296. }
  297. lstrcpy(szTheURL, pdispparams->rgvarg[5].bstrVal);
  298. #endif // UNICODE
  299. fileType = GetInetFileType(szTheURL);
  300. DebugOut("ISIGNUP: BEFORENAVIGATE got '");
  301. DebugOut(szTheURL);
  302. DebugOut("'\r\n");
  303. if( ISP_FILE != fileType)
  304. {
  305. // let IE process as normal
  306. return( S_OK );
  307. }
  308. else
  309. {
  310. // cancel the navigation
  311. //TODO UNDONE BUG what's the right way to find which argument is cancel flag?
  312. // jmazner 11/6/96 alpha build
  313. // Alpha doesn't like pbool field, but pboolVal seems to work
  314. // Should make no difference, it's just one big union
  315. //*(pdispparams->rgvarg[0].pbool) = TRUE;
  316. *(pdispparams->rgvarg[0].pboolVal) = TRUE;
  317. if (!IsCurrentlyProcessingISP())
  318. {
  319. lstrcpy( g_szISPPath, szTheURL );
  320. }
  321. GlobalFree( szTheURL );
  322. PostMessage(GetHwndMain(), WM_PROCESSISP, 0, 0);
  323. }
  324. break;
  325. case DISPID_NAVIGATECOMPLETE:
  326. DebugOut("CDExplorerEvents::Invoke (DISPID_NAVIGATECOMPLETE) called\r\n");
  327. if( NeedBackupSecurity() && !fAlreadyBackedUpSecurity )
  328. {
  329. if( !CreateSecurityPatchBackup() )
  330. {
  331. DebugOut("ISIGN32: CreateSecurityPatchBackup Failed!!\r\n");
  332. }
  333. fAlreadyBackedUpSecurity = TRUE;
  334. }
  335. break;
  336. case DISPID_STATUSTEXTCHANGE:
  337. DebugOut("CDExplorerEvents::Invoke (DISPID_STATUSTEXTCHANGE) called\r\n");
  338. break;
  339. case DISPID_QUIT:
  340. DebugOut("CDExplorerEvents::Invoke (DISPID_QUIT) called\r\n");
  341. // browser is about to cloes itself down, so g_iwbapp is about to become invalid
  342. if( g_pCP && g_pMySink)
  343. {
  344. hresult = g_pCP->Unadvise(g_pMySink->m_dwCookie);
  345. if ( FAILED( hresult ) )
  346. {
  347. DebugOut("ISIGNUP: KillSink unadvise failed\r\n");
  348. }
  349. g_pMySink->m_dwCookie = 0;
  350. g_pCP->Release();
  351. g_pCP = NULL;
  352. }
  353. if( g_iwbapp )
  354. {
  355. g_iwbapp->Release();
  356. g_iwbapp = NULL;
  357. }
  358. PostMessage(GetHwndMain(), WM_CLOSE, 0, 0);
  359. break;
  360. case DISPID_DOWNLOADCOMPLETE :
  361. DebugOut("CDExplorerEvents::Invoke (DISPID_DOWNLOADCOMPLETE) called\r\n");
  362. break;
  363. case DISPID_COMMANDSTATECHANGE:
  364. DebugOut("CDExplorerEvents::Invoke (DISPID_COMMANDSTATECHANGE) called\r\n");
  365. break;
  366. case DISPID_DOWNLOADBEGIN:
  367. DebugOut("CDExplorerEvents::Invoke (DISPID_DOWNLOADBEGIN) called\r\n");
  368. break;
  369. case DISPID_NEWWINDOW:
  370. DebugOut("CDExplorerEvents::Invoke (DISPID_NEWWINDOW) called\r\n");
  371. break;
  372. case DISPID_PROGRESSCHANGE:
  373. DebugOut("CDExplorerEvents::Invoke (DISPID_PROGRESS) called\r\n");
  374. break;
  375. case DISPID_WINDOWMOVE :
  376. DebugOut("CDExplorerEvents::Invoke (DISPID_WINDOWMOVE) called\r\n");
  377. break;
  378. case DISPID_WINDOWRESIZE :
  379. DebugOut("CDExplorerEvents::Invoke (DISPID_WINDOWRESIZE) called\r\n");
  380. break;
  381. case DISPID_WINDOWACTIVATE :
  382. DebugOut("CDExplorerEvents::Invoke (DISPID_WINDOWACTIVATE) called\r\n");
  383. break;
  384. case DISPID_PROPERTYCHANGE :
  385. DebugOut("CDExplorerEvents::Invoke (DISPID_PROPERTYCHANGE) called\r\n");
  386. break;
  387. case DISPID_TITLECHANGE:
  388. DebugOut("CDExplorerEvents::Invoke (DISPID_TITLECHANGE) called\r\n");
  389. break;
  390. default:
  391. DebugOut("CDExplorerEvents::Invoke (Unkwown) called\r\n");
  392. break;
  393. }
  394. return S_OK;
  395. }
  396. //+---------------------------------------------------------------------------
  397. //
  398. // Function: GetConnectionPoint
  399. //
  400. // Synopsis: Gets a connection point from IE so that we can become an event sync
  401. //
  402. // Arguments: none
  403. //
  404. // Returns: pointer to connection point; returns NULL if couldn't connect
  405. //
  406. // History: 9/27/96 jmazner created; mostly stolen from josephh who stole from Inside OLE
  407. //----------------------------------------------------------------------------
  408. IConnectionPoint * GetConnectionPoint(void)
  409. {
  410. HRESULT hr;
  411. IConnectionPointContainer *pCPCont = NULL;
  412. IConnectionPoint *pCP = NULL;
  413. if (!g_iwbapp)
  414. return (NULL);
  415. hr = g_iwbapp->QueryInterface(IID_IConnectionPointContainer, (VOID * *)&pCPCont);
  416. if ( FAILED(hr) )
  417. {
  418. DebugOut("ISIGNUP: GetConnectionPoint unable to QI for IConnectionPointContainter:IWebBrowserApp\r\n");
  419. return NULL;
  420. }
  421. hr=pCPCont->FindConnectionPoint(
  422. DIID_DWebBrowserEvents,
  423. &pCP
  424. );
  425. if ( FAILED(hr) )
  426. {
  427. DebugOut("ISIGNUP: GetConnectionPoint failed on FindConnectionPoint:IWebBrowserApp\r\n");
  428. pCPCont->Release();
  429. return NULL;
  430. }
  431. hr = pCPCont->Release();
  432. if ( FAILED(hr) )
  433. {
  434. DebugOut("ISIGNUP: WARNING: GetConnectionPoint failed on pCPCont->Release()\r\n");
  435. }
  436. return pCP;
  437. }
  438. //+---------------------------------------------------------------------------
  439. //
  440. // Function: KillOle
  441. //
  442. // Synopsis: Cleans up all the OLE pointers and references that we used
  443. //
  444. // Arguments: none
  445. //
  446. // Returns: hresult of any operation that failed; if nothing fails, then returns
  447. // a SUCCESS hresult
  448. //
  449. // History: 9/27/96 jmazner created;
  450. //----------------------------------------------------------------------------
  451. HRESULT KillOle( void )
  452. {
  453. HRESULT hresult = S_OK;
  454. BOOL bAlreadyDead = TRUE;
  455. if( g_iwbapp )
  456. {
  457. bAlreadyDead = FALSE;
  458. hresult = g_iwbapp->Release();
  459. if ( FAILED( hresult ) )
  460. {
  461. DebugOut("ISIGNUP: g_iwbapp->Release() unadvise failed\r\n");
  462. }
  463. g_iwbapp = NULL;
  464. }
  465. if( g_pCP && !bAlreadyDead && g_pMySink)
  466. {
  467. hresult = g_pCP->Unadvise(g_pMySink->m_dwCookie);
  468. if ( FAILED( hresult ) )
  469. {
  470. DebugOut("ISIGNUP: KillSink unadvise failed\r\n");
  471. }
  472. g_pMySink->m_dwCookie = 0;
  473. if (g_pCP) g_pCP->Release();
  474. g_pCP = NULL;
  475. }
  476. if( g_pMySink )
  477. {
  478. //delete (g_pMySink);
  479. //
  480. // 5/10/97 ChrisK Windows NT Bug 82032
  481. //
  482. g_pMySink->Release();
  483. g_pMySink = NULL;
  484. }
  485. CoUninitialize();
  486. return( hresult );
  487. }
  488. //+---------------------------------------------------------------------------
  489. //
  490. // Function: InitOle
  491. //
  492. // Synopsis: Fire up the OLE bits that we'll need, establish the Interface pointer to IE
  493. //
  494. // Arguments: none
  495. //
  496. // Returns: hresult of any operation that failed; if nothing fails, then returns
  497. // a SUCCESS hresult
  498. //
  499. // History: 9/27/96 jmazner created; mostly stolen from josephh who stole from Inside OLE
  500. //----------------------------------------------------------------------------
  501. HRESULT InitOle( void )
  502. {
  503. IUnknown FAR * punk;
  504. HRESULT hresult;
  505. hresult = CoInitialize( NULL );
  506. if( FAILED(hresult) )
  507. {
  508. DebugOut("ISIGNUP: CoInitialize failed\n");
  509. return( hresult );
  510. }
  511. hresult = CoCreateInstance (
  512. CLSID_InternetExplorer,
  513. NULL, //Not part of an agregate object
  514. CLSCTX_LOCAL_SERVER, //I hope...
  515. IID_IUnknown,
  516. (void FAR * FAR*) & punk
  517. );
  518. if( FAILED(hresult) )
  519. {
  520. DebugOut("ISIGNUP: CoCreateInstance failed\n");
  521. return( hresult );
  522. }
  523. hresult = punk->QueryInterface(IID_IWebBrowserApp,
  524. (void FAR* FAR*)&(g_iwbapp) );
  525. if( FAILED(hresult) )
  526. {
  527. DebugOut("ISIGNUP: punk->QueryInterface on IID_IWebBrowserApp failed\n");
  528. return( hresult );
  529. }
  530. //UNDONE TODO BUG do we need to do this?
  531. g_iwbapp->AddRef();
  532. punk->Release();
  533. punk = NULL;
  534. return( hresult );
  535. }
  536. typedef HRESULT (WINAPI *URLDOWNLOADTOCACHEFILE)(LPUNKNOWN,LPCWSTR,LPWSTR,DWORD,DWORD,LPBINDSTATUSCALLBACK);
  537. #define ICWSETTINGSPATH TEXT("Software\\Microsoft\\Internet Connection Wizard")
  538. #define ICWENABLEURLDOWNLOADTOCACHEFILE TEXT("URLDownloadToCacheFileW")
  539. //+----------------------------------------------------------------------------
  540. // This is a temporary work around to allow the testing team to continue
  541. // testing while allowing the IE team to debug a problem with
  542. // URLDownloadToCacheFileW
  543. // UNDONE : BUGBUG
  544. //-----------------------------------------------------------------------------
  545. BOOL EnableURLDownloadToCacheFileW()
  546. {
  547. HKEY hkey = NULL;
  548. BOOL bRC = FALSE;
  549. DWORD dwType = 0;
  550. DWORD dwData = 0;
  551. DWORD dwSize = sizeof(dwData);
  552. if (ERROR_SUCCESS != RegOpenKey(HKEY_LOCAL_MACHINE,ICWSETTINGSPATH,&hkey))
  553. goto EnableURLDownloadToCacheFileWExit;
  554. if (ERROR_SUCCESS != RegQueryValueEx(hkey,
  555. ICWENABLEURLDOWNLOADTOCACHEFILE,0,&dwType,(LPBYTE)&dwData,&dwSize))
  556. goto EnableURLDownloadToCacheFileWExit;
  557. bRC = (dwData != 0);
  558. EnableURLDownloadToCacheFileWExit:
  559. if (NULL != hkey)
  560. RegCloseKey(hkey);
  561. hkey = NULL;
  562. if (bRC)
  563. DebugOut("ISIGNUP: URLDownloadToCacheFileW ENABLED.\n");
  564. else
  565. DebugOut("ISIGNUP: URLDownloadToCacheFileW disabled.\n");
  566. return bRC;
  567. }
  568. //+---------------------------------------------------------------------------
  569. //
  570. // Function: IENavigate
  571. //
  572. // Synopsis: Converts ASCII URL to Unicode and tells IE to navigate to it
  573. //
  574. // Arguments: CHAR * szURL -- ASCII URL to navigate to
  575. //
  576. // Returns: hresult of any operation that failed; if nothing fails, then returns
  577. // a SUCCESS hresult
  578. //
  579. // History: 9/27/96 jmazner created; mostly stolen from josephh who stole from Inside OLE
  580. //----------------------------------------------------------------------------
  581. HRESULT IENavigate( TCHAR *szURL )
  582. {
  583. HRESULT hresult;
  584. DWORD dwresult;
  585. BSTR bstr = NULL;
  586. WCHAR * szWide = NULL; // Used to store unicode version of URL to open
  587. int iWideSize = 0;
  588. HINSTANCE hUrlMon = NULL;
  589. FARPROC fp = NULL;
  590. WCHAR szCacheFile[MAX_PATH];
  591. #ifndef UNICODE
  592. iWideSize = MultiByteToWideChar( CP_ACP,
  593. MB_PRECOMPOSED,
  594. szURL,
  595. -1,
  596. NULL,
  597. 0);
  598. if( 0 == iWideSize )
  599. {
  600. DebugOut("ISIGNUP: IENavigate couldn't determine size for szWide");
  601. dwresult = GetLastError();
  602. hresult = HRESULT_FROM_WIN32( dwresult );
  603. goto IENavigateExit;
  604. }
  605. szWide = (WCHAR *) GlobalAlloc( GPTR, sizeof(WCHAR) * iWideSize );
  606. if( !szWide )
  607. {
  608. DebugOut("ISIGNUP: IENavigate couldn't alloc memory for szWide");
  609. hresult = HRESULT_FROM_WIN32( ERROR_NOT_ENOUGH_MEMORY );
  610. goto IENavigateExit;
  611. }
  612. dwresult = MultiByteToWideChar( CP_ACP,
  613. MB_PRECOMPOSED,
  614. szURL,
  615. -1,
  616. szWide,
  617. iWideSize);
  618. if( 0 == dwresult )
  619. {
  620. DebugOut("ISIGNUP: IENavigate couldn't convert ANSI URL to Unicdoe");
  621. GlobalFree( szWide );
  622. szWide = NULL;
  623. dwresult = GetLastError();
  624. hresult = HRESULT_FROM_WIN32( dwresult );
  625. goto IENavigateExit;
  626. }
  627. #endif
  628. // 4/15/97 - ChrisK Olympus 131
  629. // Download the initial URL in order to see if the page is available
  630. if (NULL == (hUrlMon = LoadLibrary(TEXT("URLMON.DLL"))))
  631. {
  632. hresult = HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND);
  633. goto IENavigateExit;
  634. }
  635. if (NULL == (fp = GetProcAddress(hUrlMon,"URLDownloadToCacheFileW")))
  636. {
  637. hresult = HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND);
  638. goto IENavigateExit;
  639. }
  640. if (FALSE != EnableURLDownloadToCacheFileW())
  641. {
  642. // iBSC = new CBindStatusCallback(NULL, NULL, NULL, NULL);
  643. #ifdef UNICODE
  644. hresult = ((URLDOWNLOADTOCACHEFILE)fp)(NULL, szURL, szCacheFile, sizeof(szCacheFile), 0, NULL);
  645. #else
  646. hresult = ((URLDOWNLOADTOCACHEFILE)fp)(NULL, szWide, szCacheFile, sizeof(szCacheFile), 0, NULL);
  647. #endif
  648. if (S_OK != hresult)
  649. goto IENavigateExit;
  650. }
  651. #ifdef UNICODE
  652. bstr = SysAllocString(szURL);
  653. #else
  654. bstr = SysAllocString(szWide);
  655. #endif
  656. if( !bstr )
  657. {
  658. DebugOut("ISIGNUP: IENavigate couldn't alloc memory for bstr");
  659. hresult = HRESULT_FROM_WIN32( ERROR_NOT_ENOUGH_MEMORY );
  660. goto IENavigateExit;
  661. }
  662. VARIANT vFlags ;
  663. VARIANT vTargetFrameName;
  664. VARIANT vPostData ;
  665. VARIANT vHeaders ;
  666. VariantInit (&vFlags);
  667. VariantInit (&vTargetFrameName);
  668. VariantInit (&vPostData);
  669. VariantInit (&vHeaders);
  670. V_VT(&vFlags) = VT_ERROR;
  671. V_ERROR(&vFlags) = DISP_E_PARAMNOTFOUND;
  672. V_VT(&vTargetFrameName) = VT_ERROR;
  673. V_ERROR(&vTargetFrameName) = DISP_E_PARAMNOTFOUND;
  674. V_VT(&vPostData) = VT_ERROR;
  675. V_ERROR(&vPostData) = DISP_E_PARAMNOTFOUND;
  676. V_VT(&vHeaders) = VT_ERROR;
  677. V_ERROR(&vHeaders) = DISP_E_PARAMNOTFOUND;
  678. hresult = g_iwbapp->Navigate(
  679. bstr,
  680. &vFlags, //Flags
  681. &vTargetFrameName, //TargetFrameName
  682. &vPostData, //PostData,
  683. &vHeaders); // Headers,
  684. IENavigateExit:
  685. #ifndef UNICODE
  686. if( szWide )
  687. {
  688. GlobalFree( szWide );
  689. szWide = NULL;
  690. }
  691. #endif
  692. if (NULL != hUrlMon)
  693. FreeLibrary(hUrlMon);
  694. if (NULL != bstr)
  695. SysFreeString( bstr );
  696. return( hresult );
  697. }
  698.