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.

213 lines
5.1 KiB

  1. //
  2. // MODULE: APGTSFST.H
  3. //
  4. // PURPOSE: Creates a list of available trouble shooters.
  5. //
  6. // PROJECT: Generic Troubleshooter DLL for Microsoft AnswerPoint
  7. //
  8. // COMPANY: Saltmine Creative, Inc. (206)-633-4743 [email protected]
  9. //
  10. // AUTHOR: Richard Meadows
  11. //
  12. // ORIGINAL DATE: 6/4/96
  13. //
  14. // NOTES:
  15. // 1. Based on Print Troubleshooter DLL.
  16. //
  17. // Version Date By Comments
  18. //--------------------------------------------------------------------
  19. // V0.1 - RM Original
  20. // V0.3 04/09/98 JM/OK+ Local Version for NT5
  21. //
  22. #include "stdafx.h"
  23. #include "TSHOOT.h"
  24. #include "ErrorEnums.h"
  25. #include "apgts.h"
  26. #include "ErrorEnums.h"
  27. #include "BasicException.h"
  28. #include "apgtsfst.h"
  29. #include "ErrorEnums.h"
  30. #include "bnts.h"
  31. #include "BackupInfo.h"
  32. #include "cachegen.h"
  33. #include "apgtsinf.h"
  34. #include "apgtscmd.h"
  35. #include "apgtshtx.h"
  36. #include "apgtscls.h"
  37. CFirstPage::CFirstPage()
  38. {
  39. m_strFpResourcePath = _T("");
  40. m_bKeyOpen = FALSE;
  41. m_hKey = NULL;
  42. return;
  43. }
  44. CFirstPage::~CFirstPage()
  45. {
  46. if (m_bKeyOpen)
  47. RegCloseKey(m_hKey);
  48. return;
  49. }
  50. void CFirstPage::OpenRegKeys()
  51. {
  52. DWORD dwSize;
  53. DWORD dwType;
  54. long lErr;
  55. DWORD dwDisposition = 0;
  56. CString strRegKey;
  57. CString strBuf1;
  58. strRegKey.Format(_T("%s\\%s"), TSREGKEY_MAIN, REGSZ_TSTYPES);
  59. m_hKey = NULL;
  60. m_bKeyOpen = FALSE;
  61. // Find the resource directory.
  62. if (RegCreateKeyEx( HKEY_LOCAL_MACHINE,
  63. TSREGKEY_MAIN,
  64. 0,
  65. TS_REG_CLASS,
  66. REG_OPTION_NON_VOLATILE,
  67. KEY_READ | KEY_WRITE,
  68. NULL,
  69. &m_hKey,
  70. &dwDisposition) == ERROR_SUCCESS)
  71. {
  72. m_bKeyOpen = TRUE;
  73. if (dwDisposition == REG_OPENED_EXISTING_KEY)
  74. {
  75. dwSize = MAXBUF - 1;
  76. dwType = REG_SZ;
  77. if ((lErr = RegQueryValueEx(m_hKey,
  78. FULLRESOURCE_STR,
  79. 0,
  80. &dwType,
  81. (LPBYTE) m_strFpResourcePath.GetBufferSetLength(MAXBUF),
  82. &dwSize)) == ERROR_SUCCESS)
  83. {
  84. int len;
  85. m_strFpResourcePath.ReleaseBuffer();
  86. if (0 < (len = m_strFpResourcePath.GetLength()))
  87. {
  88. if (m_strFpResourcePath.GetAt(len - 1) != _T('\\'))
  89. m_strFpResourcePath += _T('\\');
  90. }
  91. else
  92. {
  93. strBuf1.Format(_T("%ld"),lErr);
  94. ReportWFEvent( _T("[apgtscfg]"), //Module Name
  95. _T("[GetResourceDirFromReg]"), //event
  96. (TCHAR*)(LPCTSTR) strBuf1,
  97. _T(""),
  98. EV_GTS_ERROR_CANT_OPEN_SFT_3 );
  99. CFirstPageException *pExc = new CFirstPageException;
  100. pExc->m_strError.LoadString(IDS_I_NO_TS1);
  101. throw pExc;
  102. }
  103. }
  104. else
  105. {
  106. strBuf1.Format(_T("%ld"),lErr);
  107. ReportWFEvent( _T("[apgtscfg]"), //Module Name
  108. _T("[GetResourceDirFromReg]"), //event
  109. (TCHAR*)(LPCTSTR) strBuf1,
  110. _T(""),
  111. EV_GTS_ERROR_CANT_OPEN_SFT_3 );
  112. CFirstPageException *pExc = new CFirstPageException;
  113. pExc->m_strError.LoadString(IDS_I_NO_TS1);
  114. throw pExc;
  115. }
  116. }
  117. else
  118. { // Created new key. Don't have any resources.
  119. strBuf1.Format(_T("%ld"),ERROR_REGISTRY_IO_FAILED);
  120. ReportWFEvent( _T("[apgtscfg]"), //Module Name
  121. _T("[GetResourceDirFromReg]"), //event
  122. (TCHAR*)(LPCTSTR) strBuf1,
  123. _T(""),
  124. EV_GTS_ERROR_CANT_GET_RES_PATH);
  125. CFirstPageException *pExc = new CFirstPageException;
  126. pExc->m_strError.LoadString(IDS_I_NO_TS1);
  127. throw pExc;
  128. }
  129. }
  130. else
  131. {
  132. ReportWFEvent( _T("[apgtscfg]"), //Module Name
  133. _T("[GetResourceDirFromReg]"), //event
  134. _T(""),
  135. _T(""),
  136. EV_GTS_ERROR_CANT_OPEN_SFT_2 );
  137. CFirstPageException *pExc = new CFirstPageException;
  138. pExc->m_strError.LoadString(IDS_I_NO_TS1);
  139. throw pExc;
  140. }
  141. m_bKeyOpen = FALSE;
  142. // Open the key to the trouble shooter list.
  143. if (RegCreateKeyEx( HKEY_LOCAL_MACHINE,
  144. (LPCTSTR) strRegKey,
  145. 0,
  146. TS_REG_CLASS,
  147. REG_OPTION_NON_VOLATILE,
  148. KEY_READ | KEY_WRITE,
  149. NULL,
  150. &m_hKey,
  151. &dwDisposition) == ERROR_SUCCESS)
  152. {
  153. m_bKeyOpen = TRUE;
  154. if (dwDisposition == REG_OPENED_EXISTING_KEY)
  155. {
  156. }
  157. else
  158. { // Created new key. Don't have any resources.
  159. strBuf1.Format(_T("%ld"),ERROR_REGISTRY_IO_FAILED);
  160. ReportWFEvent( _T("[apgtscfg]"), //Module Name
  161. _T("[GetResourceDirFromReg]"), //event
  162. (TCHAR*)(LPCTSTR) strBuf1,
  163. _T(""),
  164. EV_GTS_ERROR_CANT_GET_RES_PATH);
  165. CFirstPageException *pExc = new CFirstPageException;
  166. pExc->m_strError.LoadString(IDS_I_NO_TS1);
  167. throw pExc;
  168. }
  169. }
  170. else
  171. {
  172. ReportWFEvent( _T("[apgtscfg]"), //Module Name
  173. _T("[GetResourceDirFromReg]"), //event
  174. _T(""),
  175. _T(""),
  176. EV_GTS_ERROR_CANT_OPEN_SFT_2 );
  177. CFirstPageException *pExc = new CFirstPageException;
  178. pExc->m_strError.LoadString(IDS_I_NO_TS1);
  179. throw pExc;
  180. }
  181. return;
  182. }
  183. void CFirstPage::CloseRegKeys()
  184. {
  185. RegCloseKey(m_hKey);
  186. m_hKey = NULL;
  187. return;
  188. }
  189. void CFirstPage::RenderFirst(CString &strOut, CString &strTShooter)
  190. {
  191. CString strTemplate;
  192. OpenRegKeys();
  193. strOut = _T("");
  194. CInfer Infer(&strOut);
  195. strTemplate.Format(_T("%s%s.hti"), (LPCTSTR) m_strFpResourcePath, (LPCTSTR) strTShooter);
  196. CHTMLInputTemplate inputTemplate((LPCTSTR) strTemplate);
  197. Infer.LoadTShooters(m_hKey);
  198. CloseRegKeys();
  199. inputTemplate.Initialize(_T(""), _T(""));
  200. inputTemplate.SetType(_T("Unknown"));
  201. inputTemplate.SetInfer(&Infer, _T(""));
  202. inputTemplate.Print(1, &strOut);
  203. return;
  204. }