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.

96 lines
2.4 KiB

  1. #include "pre.h"
  2. #include "tutor.h"
  3. CICWTutorApp::CICWTutorApp()
  4. {
  5. //init the tutorial process structs
  6. memset(&m_StartInfo, 0, sizeof(m_StartInfo));
  7. memset(&m_ProcessInfo, 0, sizeof(m_ProcessInfo));
  8. SetTutorAppCmdLine();
  9. }
  10. CICWTutorApp::~CICWTutorApp()
  11. {
  12. DWORD dwExitCode = 0; //thread is dead
  13. if (m_ProcessInfo.hThread)
  14. {
  15. GetExitCodeThread(m_ProcessInfo.hThread, &dwExitCode);
  16. if (dwExitCode == STILL_ACTIVE)
  17. TerminateProcess(m_ProcessInfo.hProcess, 0);
  18. CloseHandle(m_ProcessInfo.hThread);
  19. CloseHandle(m_ProcessInfo.hProcess);
  20. }
  21. }
  22. void CICWTutorApp::SetTutorAppCmdLine()
  23. {
  24. if (gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAG_IEAKMODE)
  25. {
  26. //we're in IEAK mode get the path from the isp file
  27. GetPrivateProfileString(ICW_IEAK_SECTION, ICW_IEAK_TUTORCMDLN, ICW_DEFAULT_TUTOR,
  28. m_szTutorAppCmdLine, SIZE_OF_TUTOR_PATH,
  29. gpWizardState->cmnStateData.ispInfo.szISPFile);
  30. }
  31. else
  32. {
  33. TCHAR szOEMInfoPath [MAX_PATH] = TEXT("\0");
  34. //Try and get the path from the OEM file
  35. GetSystemDirectory(szOEMInfoPath, sizeof(szOEMInfoPath));
  36. lstrcat(szOEMInfoPath, TEXT("\\"));
  37. lstrcat(szOEMInfoPath, ICW_OEMINFO_FILENAME);
  38. //we're in IEAK mode get the path from the isp file
  39. GetPrivateProfileString(ICW_OEMINFO_ICWSECTION, ICW_OEMINFO_TUTORCMDLN, ICW_DEFAULT_TUTOR,
  40. m_szTutorAppCmdLine, SIZE_OF_TUTOR_PATH,
  41. szOEMInfoPath);
  42. }
  43. }
  44. BOOL CALLBACK EnumThreadWndProc(HWND hwnd, LPARAM lParam)
  45. {
  46. if(IsWindowVisible(hwnd))
  47. {
  48. SetForegroundWindow(hwnd);
  49. }
  50. return 1;
  51. }
  52. void CICWTutorApp::LaunchTutorApp()
  53. {
  54. ASSERT(m_szTutorAppCmdLine);
  55. DWORD dwExitCode = 0; //thread is dead
  56. GetExitCodeThread(m_ProcessInfo.hThread, &dwExitCode);
  57. if (dwExitCode != STILL_ACTIVE)
  58. {
  59. CloseHandle(m_ProcessInfo.hThread);
  60. CloseHandle(m_ProcessInfo.hProcess);
  61. CreateProcess(NULL,
  62. m_szTutorAppCmdLine,
  63. NULL,
  64. NULL,
  65. TRUE,
  66. 0,
  67. NULL,
  68. NULL,
  69. &m_StartInfo,
  70. &m_ProcessInfo);
  71. }
  72. else
  73. {
  74. EnumThreadWindows(m_ProcessInfo.dwThreadId, EnumThreadWndProc, 0);
  75. }
  76. }