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.

374 lines
9.3 KiB

  1. #ifndef __TSMAIN_H__
  2. #define __TSMAIN_H__
  3. /*++
  4. Copyright (C) 1997-1999 Microsoft Corporation
  5. Module Name:
  6. tsmain.h
  7. Abstract:
  8. header file for tsmain.cpp
  9. Author:
  10. William Hsieh (williamh) created
  11. Revision History:
  12. --*/
  13. //
  14. // Wizard32 command and parameter definitions
  15. //
  16. //
  17. //
  18. // INPUT:
  19. // pParam -- troubleshooter parameter. The contents vary depends on
  20. // the command specified in the block. See below
  21. // for detail.
  22. //
  23. //
  24. // OUTPUT:
  25. // TRUE -- if the function succeeded.
  26. // FALSE -- if the function failed. GetLastError() should be able
  27. // to retreive the error code
  28. typedef enum tagTShooterCommand
  29. {
  30. TSHOOTER_QUERY = 0,
  31. TSHOOTER_ABOUT,
  32. TSHOOTER_ADDPAGES
  33. }TSHOOTER_COMMAND, *PTSHOOTER_COMMAND;
  34. // parameter header.
  35. typedef struct tagTShooterParamHeader
  36. {
  37. DWORD cbSize; // size of the entire structure
  38. TSHOOTER_COMMAND Command; // command
  39. }TSHOOTER_PARAMHEADER, *PTSHOOTER_PARAMHEADER;
  40. //
  41. // QUERY command asks the troubleshooter the following questions:
  42. // (1). if the troubleshooter supports the given DeviceId/Problem combination.
  43. // (2). the brief description about the troubleshooter
  44. // (3). the ranking on the DeviceId and the problem.
  45. // If the troubleshooter does not support the device id and problem
  46. // combination, it should resturn FALSE and set the error code
  47. // to ERROR_INVALID_FUNCTION. The DescBuffer and DescBufferSize
  48. // can be ignored. If the provided DescBuffer is too small, it should
  49. // fill DescBufferSize with the required size, set the error code
  50. // to ERROR_INSUFFICIENT_BUFFER and return FALSE.
  51. //
  52. // parameter definition for TSHOOTER_QUERY command
  53. //
  54. // The Header.Command must be TSHOOTER_QUERY;
  55. // The header.cbSize must be sizeof(TSHOOTER_QUERY_PARAM);
  56. //
  57. // IN DeviceId -- device instance id
  58. // IN Problem -- Configuration manager defined problem number
  59. // IN OUT DescBuffer -- buffer to receive the troubleshooter description text
  60. // IN OUT DescBufferSize -- Description buffer size in char(byte for ANSI)
  61. // Troubleshooter should fill this field with required
  62. // size on return.
  63. // OUT DeviceRank -- to receive the device ranking
  64. // OUT ProblemRank -- to receive the problem ranking
  65. //
  66. //
  67. typedef struct tagTShooterQueryParam
  68. {
  69. TSHOOTER_PARAMHEADER Header;
  70. LPCTSTR DeviceId;
  71. ULONG Problem;
  72. LPTSTR DescBuffer;
  73. DWORD DescBufferSize;
  74. DWORD DeviceRank;
  75. DWORD ProblemRank;
  76. }TSHOOTER_QUERYPARAM, *PTSHOOTER_QUERYPARAM;
  77. // The TSHOOTER_ABOUT asks the troubleshooter to display its about dialog box.
  78. // The about dialog box should tell user what the troubleshooter is all about.
  79. //
  80. // The about dialog box is supposed to be Modal. If the troubleshooter
  81. // implements a modaless about dialog box, it should disable
  82. // the given hwndOwner after the dialog box is created and reenable
  83. // it after the dialog box is destroyed.
  84. //
  85. // parameter definition for ABOUT troubleshooter command
  86. //
  87. // Header.Command must be TSHOOTER_ABOUT;
  88. // Header.cbSize must be sizeof(TSHOOTER_ABOUT_PARAM);
  89. //
  90. // IN hwndOwner -- the window handle to serve as the owner window
  91. // of the troubleshooter about dialog box
  92. //
  93. //
  94. typedef struct tagTShooterAboutParam
  95. {
  96. TSHOOTER_PARAMHEADER Header;
  97. HWND hwndOwner;
  98. }TSHOOTER_ABOUTPARAM, *PTSHOOTER_ABOUTPARAM;
  99. //
  100. // The TSHOOTER_ADDPAGES asks the troubleshooter to add its wizard
  101. // pages to the provided property sheet header.
  102. //
  103. //
  104. // parameter definition for ADDPAGES troubleshooter command
  105. //
  106. // Header.Command must be TSHOOTER_ADDPAGRES;
  107. // Header.cbSize must be sizeof(TSHOOTER_ADDPAGES_PARAM);
  108. //
  109. // IN DeviceId -- the hardware id of the device
  110. // IN Problem -- Configuration Manager defined problem number
  111. // IN OUT ppsh -- property sheet header to which the troubleshooter
  112. // add its pages
  113. // IN MaxPages -- total pages alloated for the ppsh.
  114. // The troubleshooter should not add more than
  115. // (MaxPages - ppsh.nPages) pages
  116. //
  117. typedef struct tagTShooterAddPagesParam
  118. {
  119. TSHOOTER_PARAMHEADER Header;
  120. LPCTSTR DeviceId;
  121. ULONG Problem;
  122. LPPROPSHEETHEADER PropSheetHeader;
  123. DWORD MaxPages;
  124. }TSHOOTER_ADDPAGESPARAM, *PTSHOOTER_ADDPAGESPARAM;
  125. // Each Troubleshooting wizard must provide an entry point for Device Manager
  126. // to call:
  127. typedef BOOL (APIENTRY *WIZARDENTRY)(PTSHOOTER_PARAMHEADER pParam);
  128. typedef enum tagTShooterWizadType
  129. {
  130. TWT_ANY = 0, // any type of troubleshooter wizard
  131. TWT_PROBLEM_SPECIFIC, // problem specific wizards
  132. TWT_CLASS_SPECIFIC, // class specific wizards
  133. TWT_GENERAL_PURPOSE, // general purpose
  134. TWT_DEVMGR_DEFAULT // device manager default
  135. }TSHOOTERWIZARDTYPE, *PTSHOOTERWIZARTYPE;
  136. //
  137. // class that represent a wizard32 troubleshooter
  138. //
  139. class CWizard
  140. {
  141. public:
  142. CWizard(HMODULE hWizardDll, FARPROC WizardEntry)
  143. : m_WizardEntry((WIZARDENTRY)WizardEntry),
  144. m_hWizardDll(hWizardDll),
  145. m_Problem(0),
  146. m_DeviceRank(0),
  147. m_ProblemRank(0),
  148. m_AddedPages(0),
  149. m_pDevice(NULL)
  150. {}
  151. ~CWizard()
  152. {
  153. if (m_hWizardDll)
  154. FreeLibrary(m_hWizardDll);
  155. }
  156. LPCTSTR GetDescription()
  157. {
  158. return m_strDescription.IsEmpty() ? NULL : (LPCTSTR)m_strDescription;
  159. }
  160. virtual BOOL Query(CDevice* pDevice, ULONG Problem);
  161. virtual BOOL About(HWND hwndOwner);
  162. virtual BOOL AddPages(LPPROPSHEETHEADER ppsh, DWORD MaxPages);
  163. ULONG DeviceRank()
  164. {
  165. return m_DeviceRank;
  166. }
  167. ULONG ProblemRank()
  168. {
  169. return m_ProblemRank;
  170. }
  171. UINT m_AddedPages;
  172. protected:
  173. WIZARDENTRY m_WizardEntry;
  174. HINSTANCE m_hWizardDll;
  175. String m_strDescription;
  176. ULONG m_Problem;
  177. ULONG m_DeviceRank;
  178. ULONG m_ProblemRank;
  179. CDevice* m_pDevice;
  180. };
  181. //
  182. // Class that collects all available troubleshooter
  183. //
  184. class CWizardList
  185. {
  186. public:
  187. CWizardList(TSHOOTERWIZARDTYPE Type = TWT_ANY) : m_Type(Type)
  188. {}
  189. ~CWizardList();
  190. BOOL Create(CDevice* pDevice, ULONG Problem);
  191. int NumberOfWizards()
  192. {
  193. return m_listWizards.GetCount();
  194. }
  195. BOOL GetFirstWizard(CWizard** ppWizard, PVOID* pContext);
  196. BOOL GetNextWizard(CWizard** ppWizard, PVOID& Context);
  197. private:
  198. BOOL CreateWizardsFromStrings(LPTSTR msz, CDevice* pDevice, ULONG Problem);
  199. CList<CWizard*, CWizard*> m_listWizards;
  200. TSHOOTERWIZARDTYPE m_Type;
  201. };
  202. //
  203. // class that represents the troubleshooter wizard introduction page
  204. //
  205. class CWizardIntro : public CPropSheetPage
  206. {
  207. public:
  208. CWizardIntro() : m_pDevice(NULL), m_hFontBold(NULL),
  209. m_hFontBigBold(NULL),
  210. m_pSelectedWizard(NULL), m_Problem(0),
  211. CPropSheetPage(g_hInstance, IDD_WIZINTRO)
  212. {
  213. }
  214. virtual ~CWizardIntro()
  215. {
  216. if (m_hFontBold)
  217. DeleteObject(m_hFontBold);
  218. if (m_hFontBigBold)
  219. DeleteObject(m_hFontBigBold);
  220. }
  221. virtual BOOL OnInitDialog(LPPROPSHEETPAGE ppsp);
  222. virtual BOOL OnWizNext();
  223. virtual BOOL OnSetActive();
  224. virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
  225. HPROPSHEETPAGE Create(CDevice* pDevice);
  226. private:
  227. CDevice* m_pDevice;
  228. HFONT m_hFontBold;
  229. HFONT m_hFontBigBold;
  230. CWizardList m_Wizards;
  231. ULONG m_Problem;
  232. CWizard* m_pSelectedWizard;
  233. };
  234. //
  235. // class that represents the troubleshooter property sheet
  236. //
  237. class CWizard98
  238. {
  239. public:
  240. CWizard98(HWND hwndParent, UINT MaxPages = 32);
  241. BOOL CreateIntroPage(CDevice* pDevice);
  242. UINT GetMaxPages()
  243. {
  244. return m_MaxPages;
  245. }
  246. INT_PTR DoSheet()
  247. {
  248. return ::PropertySheet(&m_psh);
  249. }
  250. PROPSHEETHEADER m_psh;
  251. private:
  252. CDevice* m_pDevice;
  253. UINT m_MaxPages;
  254. };
  255. class CTSLauncher
  256. {
  257. public:
  258. CTSLauncher() : m_hTSL(NULL)
  259. {}
  260. ~CTSLauncher()
  261. {
  262. Close();
  263. }
  264. BOOL Open(LPCTSTR DeviceId, const GUID& ClassGuid, ULONG Problem)
  265. {
  266. return FALSE;
  267. }
  268. BOOL Close()
  269. {
  270. m_hTSL = NULL;
  271. return TRUE;
  272. }
  273. BOOL Go()
  274. {
  275. return FALSE;
  276. }
  277. BOOL EnumerateStatus(int Index, DWORD& Status)
  278. {
  279. return FALSE;
  280. }
  281. private:
  282. HANDLE m_hTSL;
  283. };
  284. #if 0
  285. typedef enum tagFixItCommand
  286. {
  287. FIXIT_COMMAND_DONOTHING = 0,
  288. FIXIT_COMMAND_UPGRADEDRIVERS,
  289. FIXIT_COMMAND_REINSTALL,
  290. FIXIT_COMMAND_ENABLEDEVICE
  291. FIXIT_COMMAND_RESTARTCOMPUTER
  292. } FIXIT_COMMAND, *PFIXIT_COMMAND;
  293. class CProblemAgent
  294. {
  295. public:
  296. CProblemAgent(CDevice* pDevice, ULONG Problem, ULONG Status);
  297. ~CProblemAgent();
  298. // retreive the problem description text
  299. LPCTSTR ProblemText()
  300. {
  301. return m_strDescription.IsEmpty() ? NULL : (LPCTSTR)m_strDescription;
  302. }
  303. LPCTSTR InstructionText()
  304. {
  305. return m_strInstruction.IsEmpty() ? NULL : (LPCTSTR)m_strInstruction;
  306. }
  307. // fix the problem
  308. virtual BOOL FixIt(HWND hwndOwner)
  309. {
  310. return TRUE;
  311. }
  312. protected:
  313. BOOL UpdateDriver(HWND hwndOwner, m_pDevice);
  314. BOOL Reinstall(HWND hwndOwner);
  315. BOOL RestartComputer(HWND hwndOwner);
  316. BOOL EnableDevice()
  317. CDevice* m_pDevice;
  318. ULONG m_Problem;
  319. ULONG m_Status;
  320. String m_strDescription;
  321. String m_strInstruction;
  322. FIXITCOMMAND m_Command;
  323. };
  324. #endif
  325. INT_PTR
  326. StartTroubleshootingWizard(
  327. HWND hWndParent,
  328. CDevice* pDevice
  329. );
  330. #endif // __PROBLEM_H__