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.

204 lines
5.0 KiB

  1. // HotfixOCX.cpp : Implementation of CHotfixOCX
  2. #include "stdafx.h"
  3. #include "HotfixManager.h"
  4. #include "HotfixOCX.h"
  5. #include <Windows.h>
  6. #include <commctrl.h>
  7. #include <stdio.h>
  8. #include <comdef.h>
  9. /////////////////////////////////////////////////////////////////////////////
  10. // CHotfixOCX
  11. BOOL CHotfixOCX::ResizeButtons(RECT *rc)
  12. {
  13. ::MoveWindow(WebButton,
  14. rc->left+40,
  15. rc->bottom - 40,
  16. 100,
  17. 28,
  18. TRUE);
  19. ::MoveWindow(UninstButton,
  20. rc->left+180,
  21. rc->bottom - 40,
  22. 100,
  23. 28,
  24. TRUE);
  25. ::MoveWindow(RptButton,
  26. rc->left+320,
  27. rc->bottom - 40,
  28. 100,
  29. 28,
  30. TRUE);
  31. return TRUE;
  32. }
  33. BOOL CHotfixOCX::CreateButton( HINSTANCE hInst, HWND hWnd, RECT * rc)
  34. {
  35. _TCHAR Temp[255];
  36. DWORD dwSize = 255;
  37. BOOL bSuccess = TRUE;
  38. LoadString(hInst,IDS_BN_VIEW_WEB, Temp,dwSize);
  39. WebButton = CreateWindow (_T("button"), Temp,WS_CHILD | BS_DEFPUSHBUTTON|WS_VISIBLE,0,0,0,0,hWnd,(HMENU) IDC_WEB_BUTTON,hInst,NULL);
  40. LoadString(hInst,IDS_BN_UNINSTALL, Temp,dwSize);
  41. UninstButton = CreateWindow (_T("button"), Temp,WS_CHILD | BS_PUSHBUTTON|WS_VISIBLE,0,0,0,0,hWnd,(HMENU) IDC_UNINST_BUTTON,hInst,NULL);
  42. LoadString(hInst,IDS_BN_PRINT_REPORT, Temp,dwSize);
  43. RptButton = CreateWindow (_T("button"), Temp,WS_CHILD | BS_PUSHBUTTON|WS_VISIBLE,0,0,0,0,hWnd,(HMENU) IDC_RPT_BUTTON,hInst,NULL);
  44. /* if(!hButton)
  45. return NULL;*/
  46. NONCLIENTMETRICS ncm;
  47. HFONT hFont;
  48. ncm.cbSize = sizeof(ncm);
  49. SystemParametersInfo(SPI_GETNONCLIENTMETRICS,sizeof (ncm),&ncm,0);
  50. // _tcscpy(ncm.lfMenuFont.lfFaceName,_T("MS Shell Dlg"));
  51. // = _T("MS Shell Dlg");
  52. hFont = CreateFontIndirect(&ncm.lfMenuFont);
  53. SendMessage(WebButton,WM_SETFONT, (WPARAM)hFont ,MAKELPARAM(TRUE, 0));
  54. SendMessage(UninstButton,WM_SETFONT, (WPARAM)hFont ,MAKELPARAM(TRUE, 0));
  55. SendMessage(RptButton,WM_SETFONT, (WPARAM)hFont ,MAKELPARAM(TRUE, 0));
  56. // MessageBox(NULL,_T("Got the Button Created"),_T(""),MB_OK);
  57. ResizeButtons(rc);
  58. return TRUE;
  59. }
  60. BOOL CHotfixOCX::ShowWebPage(_TCHAR *HotFix)
  61. {
  62. char temp[255];
  63. char Command[255];
  64. if (_tcscmp(HotFix,_T("\0")))
  65. {
  66. wcstombs(temp,HotFix,255);
  67. sprintf(Command, "Explorer.exe \"http://Support.Microsoft.com/Support/Misc/KbLookup.asp?ID=%s\"", temp+1);
  68. //MessageBox(Command,NULL,MB_OK);
  69. WinExec( (char*)Command, SW_SHOWNORMAL);
  70. }
  71. return TRUE;
  72. }
  73. STDMETHODIMP CHotfixOCX::get_Command(long *pVal)
  74. {
  75. // TODO: Add your implementation code here
  76. return S_OK;
  77. }
  78. STDMETHODIMP CHotfixOCX::put_Command(long newVal)
  79. {
  80. // TODO: Add your implementation code here
  81. switch (newVal)
  82. {
  83. case IDC_VIEW_BY_FILE:
  84. // Change the current view type to by file.
  85. ListViews.SetViewMode(VIEW_BY_FILE);
  86. break;
  87. case IDC_VIEW_BY_HOTFIX:
  88. // Change the current view type to by hotfix
  89. ListViews.SetViewMode(VIEW_BY_HOTFIX);
  90. break;
  91. case IDC_UNINSTALL:
  92. // Uninstall the current hotfix if pointing at the local system
  93. ListViews.Uninstall();
  94. break;
  95. case IDC_VIEW_WEB:
  96. // View the web page for the current hotfix
  97. ShowWebPage(ListViews.GetCurrentHotfix());
  98. break;
  99. case IDC_EXPORT:
  100. ListViews.SaveToCSV();
  101. // Generate a report for the current system
  102. break;
  103. case IDC_PRINT_REPORT:
  104. ListViews.PrintReport();
  105. break;
  106. }
  107. return S_OK;
  108. }
  109. STDMETHODIMP CHotfixOCX::get_ComputerName(BSTR *pVal)
  110. {
  111. // TODO: Add your implementation code here
  112. // Return the name of the current target computer.
  113. return S_OK;
  114. }
  115. STDMETHODIMP CHotfixOCX::put_ComputerName(BSTR newVal)
  116. {
  117. // TODO: Add your implementation code here
  118. // Set the name of the target computer.
  119. //_bstr_t Val(newVal,FALSE);
  120. _tcscpy(ComputerName,newVal);
  121. ListViews.Initialize(ComputerName);
  122. return S_OK;
  123. }
  124. STDMETHODIMP CHotfixOCX::get_ProductName(BSTR *pVal)
  125. {
  126. // TODO: Add your implementation code here
  127. return S_OK;
  128. }
  129. STDMETHODIMP CHotfixOCX::put_ProductName(BSTR newVal)
  130. {
  131. _TCHAR Temp[255];
  132. // TODO: Add your implementation code here
  133. // Set the name of the current producted selected in the snap-in scope tree.
  134. // _bstr_t Val(newVal,FALSE);
  135. _tcscpy (Temp,newVal);
  136. // MessageBox(Temp,_T("Recieved....."),MB_OK);
  137. ListViews.SetProductName(Temp);
  138. return S_OK;
  139. }
  140. STDMETHODIMP CHotfixOCX::get_ViewState(long *pVal)
  141. {
  142. // TODO: Add your implementation code here
  143. *pVal = ListViews.GetCurrentView();
  144. return S_OK;
  145. }
  146. STDMETHODIMP CHotfixOCX::get_Remoted(BOOL *pVal)
  147. {
  148. // TODO: Add your implementation code here
  149. *pVal = ListViews.m_bRemoted;
  150. return S_OK;
  151. }
  152. STDMETHODIMP CHotfixOCX::get_HaveHotfix(BOOL *pVal)
  153. {
  154. // TODO: Add your implementation code here
  155. if (_tcscmp( ListViews.m_CurrentHotfix, _T("\0")))
  156. *pVal = TRUE;
  157. else
  158. *pVal = FALSE;
  159. return S_OK;
  160. }
  161. STDMETHODIMP CHotfixOCX::get_CurrentState(long *pVal)
  162. {
  163. // TODO: Add your implementation code here
  164. *pVal = ListViews.GetState();
  165. return S_OK;
  166. }