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.

202 lines
4.4 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. BSTR Str;
  59. hr = CoCreateInstance(
  60. CLSID_InternetExplorer,
  61. NULL,
  62. CLSCTX_LOCAL_SERVER,
  63. IID_IWebBrowserApp,
  64. (void **)&pwb
  65. );
  66. if (SUCCEEDED(hr)) {
  67. // turn off chrome
  68. hr = pwb->put_MenuBar(FALSE);
  69. hr = pwb->put_StatusBar(FALSE);
  70. // hr = pwb->put_ToolBar(FALSE);
  71. // set client area size
  72. int iWidth = 466L;
  73. int iHeight = 286L;
  74. pwb->ClientToWindow(&iWidth, &iHeight);
  75. if (iWidth > 0)
  76. pwb->put_Width(iWidth);
  77. if (iHeight > 0)
  78. pwb->put_Height(iHeight);
  79. if ((dx = ((GetSystemMetrics(SM_CXSCREEN) - iWidth) / 2)) > 0) // center the on screen window
  80. pwb->put_Left(dx);
  81. if ((dy = ((GetSystemMetrics(SM_CYSCREEN) - iHeight) / 2)) > 0)
  82. pwb->put_Top(dy);
  83. pwb->put_Visible(TRUE);
  84. Str = szResourceURL;
  85. hr = pwb->Navigate(Str, PVAREMPTY, PVAREMPTY, PVAREMPTY, PVAREMPTY);
  86. pwb->Release();
  87. return(TRUE);
  88. }
  89. return(FALSE);
  90. }
  91. BOOL
  92. LaunchIE4Instance(
  93. LPWSTR szResourceURL
  94. )
  95. {
  96. HRESULT hr;
  97. int dx, dy;
  98. IWebBrowser2 *pwb;
  99. BSTR Str;
  100. hr = CoCreateInstance(
  101. CLSID_InternetExplorer,
  102. NULL,
  103. CLSCTX_LOCAL_SERVER,
  104. IID_IWebBrowser2,
  105. (void **)&pwb
  106. );
  107. if (SUCCEEDED(hr)) {
  108. //
  109. // this marks this window as a third party window,
  110. // so that the window is not reused.
  111. //
  112. pwb->put_RegisterAsBrowser(VARIANT_TRUE);
  113. IHTMLWindow2 *phw;
  114. IServiceProvider *psp;
  115. if (SUCCEEDED(pwb->QueryInterface(IID_IServiceProvider, (void**) &psp)) && psp) {
  116. if (SUCCEEDED(psp->QueryService(IID_IHTMLWindow2, IID_IHTMLWindow2, (void**)&phw))) {
  117. VARIANT var;
  118. var.vt = VT_BOOL;
  119. var.boolVal = 666;
  120. phw->put_opener(var);
  121. phw->Release();
  122. } else
  123. MessageBox(NULL, TEXT("QueryInterface of IID_IHTMLWindow2 FAILED!!!!!"), NULL, MB_ICONERROR);
  124. psp->Release();
  125. }
  126. // turn off chrome
  127. pwb->put_MenuBar(FALSE);
  128. pwb->put_StatusBar(FALSE);
  129. // pwb->put_ToolBar(FALSE);
  130. pwb->put_AddressBar(FALSE);
  131. // pwb->put_Resizable(FALSE);
  132. // set client area size
  133. int iWidth = 466L;
  134. int iHeight = 286L;
  135. pwb->ClientToWindow(&iWidth, &iHeight);
  136. if (iWidth > 0)
  137. pwb->put_Width(iWidth);
  138. if (iHeight > 0)
  139. pwb->put_Height(iHeight);
  140. if ((dx = ((GetSystemMetrics(SM_CXSCREEN) - iWidth) / 2)) > 0) // center the on screen window
  141. pwb->put_Left(dx);
  142. if ((dy = ((GetSystemMetrics(SM_CYSCREEN) - iHeight) / 2)) > 0)
  143. pwb->put_Top(dy);
  144. pwb->put_Visible(TRUE);
  145. Str = szResourceURL;
  146. hr = pwb->Navigate(Str, PVAREMPTY, PVAREMPTY, PVAREMPTY, PVAREMPTY);
  147. pwb->Release();
  148. return(TRUE);
  149. }
  150. return(FALSE);
  151. }