Source code of Windows XP (NT5)
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.

200 lines
4.2 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include <windows.h>
  4. #include <ole2.h>
  5. #include <exdisp.h>
  6. #include <htiframe.h>
  7. #define INITGUID
  8. #include <initguid.h>
  9. #include <shlguid.h>
  10. #include <mshtml.h>
  11. DEFINE_MODULE( "RIPREP" )
  12. const VARIANT c_vaEmpty = {0};
  13. #define PVAREMPTY ((VARIANT*)&c_vaEmpty)
  14. BOOL
  15. IsIE3Installed(
  16. VOID
  17. )
  18. {
  19. HRESULT hr;
  20. IWebBrowserApp *pwb;
  21. hr = CoCreateInstance( CLSID_InternetExplorer,
  22. NULL,
  23. CLSCTX_LOCAL_SERVER,
  24. IID_IWebBrowserApp,
  25. (void **)&pwb );
  26. if (SUCCEEDED(hr)) {
  27. return TRUE;
  28. } else {
  29. return FALSE;
  30. }
  31. }
  32. BOOL
  33. IsIE4Installed(
  34. VOID
  35. )
  36. {
  37. HRESULT hr;
  38. IWebBrowserApp *pwb;
  39. hr = CoCreateInstance( CLSID_InternetExplorer,
  40. NULL,
  41. CLSCTX_LOCAL_SERVER,
  42. IID_IWebBrowser2,
  43. (void **)&pwb );
  44. if (SUCCEEDED(hr)) {
  45. return TRUE;
  46. } else {
  47. return FALSE;
  48. }
  49. }
  50. BOOL
  51. LaunchIE3Instance(
  52. LPWSTR szResourceURL
  53. )
  54. {
  55. HRESULT hr;
  56. int dx, dy;
  57. IWebBrowserApp *pwb;
  58. hr = CoCreateInstance(
  59. CLSID_InternetExplorer,
  60. NULL,
  61. CLSCTX_LOCAL_SERVER,
  62. IID_IWebBrowserApp,
  63. (void **)&pwb
  64. );
  65. if (SUCCEEDED(hr)) {
  66. // turn off chrome
  67. hr = pwb->put_MenuBar(FALSE);
  68. hr = pwb->put_StatusBar(FALSE);
  69. // hr = pwb->put_ToolBar(FALSE);
  70. // set client area size
  71. int iWidth = 466L;
  72. int iHeight = 286L;
  73. pwb->ClientToWindow(&iWidth, &iHeight);
  74. if (iWidth > 0)
  75. pwb->put_Width(iWidth);
  76. if (iHeight > 0)
  77. pwb->put_Height(iHeight);
  78. if ((dx = ((GetSystemMetrics(SM_CXSCREEN) - iWidth) / 2)) > 0) // center the on screen window
  79. pwb->put_Left(dx);
  80. if ((dy = ((GetSystemMetrics(SM_CYSCREEN) - iHeight) / 2)) > 0)
  81. pwb->put_Top(dy);
  82. pwb->put_Visible(TRUE);
  83. hr = pwb->Navigate(szResourceURL, PVAREMPTY, PVAREMPTY, PVAREMPTY, PVAREMPTY);
  84. pwb->Release();
  85. return(TRUE);
  86. }
  87. return(FALSE);
  88. }
  89. BOOL
  90. LaunchIE4Instance(
  91. LPWSTR szResourceURL
  92. )
  93. {
  94. HRESULT hr;
  95. int dx, dy;
  96. IWebBrowser2 *pwb;
  97. hr = CoCreateInstance(
  98. CLSID_InternetExplorer,
  99. NULL,
  100. CLSCTX_LOCAL_SERVER,
  101. IID_IWebBrowser2,
  102. (void **)&pwb
  103. );
  104. if (SUCCEEDED(hr)) {
  105. DWORD dwFlags;
  106. ITargetFrame2* ptgf;
  107. //
  108. // this marks this window as a third party window,
  109. // so that the window is not reused.
  110. //
  111. pwb->put_RegisterAsBrowser(VARIANT_TRUE);
  112. IHTMLWindow2 *phw;
  113. IServiceProvider *psp;
  114. if (SUCCEEDED(pwb->QueryInterface(IID_IServiceProvider, (void**) &psp)) && psp) {
  115. if (SUCCEEDED(psp->QueryService(IID_IHTMLWindow2, IID_IHTMLWindow2, (void**)&phw))) {
  116. VARIANT var;
  117. var.vt = VT_BOOL;
  118. var.boolVal = 666;
  119. phw->put_opener(var);
  120. phw->Release();
  121. } else
  122. MessageBox(NULL, TEXT("QueryInterface of IID_IHTMLWindow2 FAILED!!!!!"), NULL, MB_ICONERROR);
  123. psp->Release();
  124. }
  125. // turn off chrome
  126. pwb->put_MenuBar(FALSE);
  127. pwb->put_StatusBar(FALSE);
  128. // pwb->put_ToolBar(FALSE);
  129. pwb->put_AddressBar(FALSE);
  130. // pwb->put_Resizable(FALSE);
  131. // set client area size
  132. int iWidth = 466L;
  133. int iHeight = 286L;
  134. pwb->ClientToWindow(&iWidth, &iHeight);
  135. if (iWidth > 0)
  136. pwb->put_Width(iWidth);
  137. if (iHeight > 0)
  138. pwb->put_Height(iHeight);
  139. if ((dx = ((GetSystemMetrics(SM_CXSCREEN) - iWidth) / 2)) > 0) // center the on screen window
  140. pwb->put_Left(dx);
  141. if ((dy = ((GetSystemMetrics(SM_CYSCREEN) - iHeight) / 2)) > 0)
  142. pwb->put_Top(dy);
  143. pwb->put_Visible(TRUE);
  144. hr = pwb->Navigate(szResourceURL, PVAREMPTY, PVAREMPTY, PVAREMPTY, PVAREMPTY);
  145. pwb->Release();
  146. return(TRUE);
  147. }
  148. return(FALSE);
  149. }