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.

203 lines
6.4 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2001, Microsoft Corporation All rights reserved.
  4. //
  5. // Module Name:
  6. //
  7. // welcome.c
  8. //
  9. // Abstract:
  10. //
  11. // This file contains dialog to show the EULA agreement dialog of the
  12. // euroconv.exe utility.
  13. //
  14. // Revision History:
  15. //
  16. // 2001-07-30 lguindon Created.
  17. //
  18. ///////////////////////////////////////////////////////////////////////////////
  19. ///////////////////////////////////////////////////////////////////////////////
  20. //
  21. // Includes Files.
  22. //
  23. ///////////////////////////////////////////////////////////////////////////////
  24. #include "euroconv.h"
  25. #include "welcome.h"
  26. ///////////////////////////////////////////////////////////////////////////////
  27. //
  28. // Globals.
  29. //
  30. ///////////////////////////////////////////////////////////////////////////////
  31. ///////////////////////////////////////////////////////////////////////////////
  32. //
  33. // WelcomeDialogProc
  34. //
  35. // Message handler function for the EULA.
  36. //
  37. ///////////////////////////////////////////////////////////////////////////////
  38. INT_PTR CALLBACK WelcomeDialogProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  39. {
  40. HANDLE hFile;
  41. DWORD dwFileSize;
  42. DWORD dwActual;
  43. LPVOID pFileBuffer;
  44. CHAR szEulaPath[MAX_PATH];
  45. CHAR szEulaFile[MAX_PATH] = {0};
  46. switch ( uMsg )
  47. {
  48. case WM_INITDIALOG:
  49. {
  50. //
  51. // Load EULA file from the path where euroconv was launched
  52. //
  53. GetModuleFileName( NULL, szEulaPath, MAX_PATH);
  54. //
  55. // Get EULA file name.
  56. //
  57. LoadString(ghInstance, IDS_EULA, szEulaFile, MAX_PATH);
  58. //
  59. // Generate a valid path
  60. //
  61. //lstrcpy(strrchr(szEulaPath, '\\')+1, szEulaFile);
  62. StringCbCopy(strrchr(szEulaPath, '\\')+1, MAX_PATH, szEulaFile);
  63. //
  64. // Open the file
  65. //
  66. if (((hFile = CreateFile( szEulaPath,
  67. GENERIC_READ,
  68. FILE_SHARE_READ | FILE_SHARE_WRITE,
  69. NULL,
  70. OPEN_EXISTING,
  71. FILE_ATTRIBUTE_NORMAL,
  72. NULL)) != INVALID_HANDLE_VALUE) &&
  73. ((dwFileSize = GetFileSize( hFile, NULL )) != -1) &&
  74. (pFileBuffer = LocalAlloc(LPTR, dwFileSize + 1)))
  75. {
  76. //
  77. // Read the file.
  78. //
  79. if (ReadFile( hFile, pFileBuffer, dwFileSize, &dwActual, NULL ))
  80. {
  81. //
  82. // Make sure to NULL terminate the string
  83. //
  84. *((PCHAR)((PCHAR)pFileBuffer + dwFileSize)) = 0x00;
  85. //
  86. // Use ANSI text
  87. //
  88. SetDlgItemText( hWndDlg, IDC_EDIT_LICENSE, (LPCSTR)pFileBuffer );
  89. }
  90. //
  91. // Free used memory
  92. //
  93. LocalFree( pFileBuffer );
  94. }
  95. //
  96. // Change focus.
  97. //
  98. SetFocus( GetDlgItem( hWndDlg, IDC_CHECK_LICENSE ));
  99. return 0;
  100. }
  101. case WM_COMMAND:
  102. {
  103. switch (LOWORD(wParam))
  104. {
  105. case IDOK:
  106. {
  107. if (IsDlgButtonChecked(hWndDlg, IDC_CHECK_LICENSE) == BST_CHECKED)
  108. {
  109. EndDialog(hWndDlg, ERROR_SUCCESS);
  110. }
  111. else
  112. {
  113. EndDialog(hWndDlg, ERROR_CANCELLED);
  114. }
  115. return (1);
  116. }
  117. case IDCANCEL:
  118. {
  119. EndDialog(hWndDlg, ERROR_CANCELLED);
  120. return (1);
  121. }
  122. case IDC_README:
  123. {
  124. //
  125. // invoke notepad.exe open readme.txt
  126. //
  127. CHAR szReadMePath[MAX_PATH];
  128. CHAR szReadMeFile[MAX_PATH] = {0};
  129. SHELLEXECUTEINFO ExecInfo = {0};
  130. //
  131. // Load README file from the path where euroconv was launched
  132. //
  133. GetModuleFileName(NULL, szReadMePath, sizeof(szReadMePath)/sizeof(CHAR));
  134. //
  135. // Get README file name.
  136. //
  137. LoadString(ghInstance, IDS_README, szReadMeFile, MAX_PATH);
  138. //
  139. // Generate a valid path
  140. //
  141. //lstrcpy(strrchr(szReadMePath, '\\')+1, szReadMeFile);
  142. StringCbCopy(strrchr(szReadMePath, '\\')+1, MAX_PATH, szReadMeFile);
  143. ExecInfo.lpParameters = szReadMePath;
  144. ExecInfo.lpFile = "NOTEPAD.EXE";
  145. ExecInfo.nShow = SW_SHOWNORMAL;
  146. ExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
  147. ShellExecuteEx(&ExecInfo);
  148. return 1;
  149. }
  150. case IDC_CHECK_LICENSE:
  151. {
  152. EnableWindow(GetDlgItem(hWndDlg, IDOK), IsDlgButtonChecked(hWndDlg, IDC_CHECK_LICENSE) == BST_CHECKED);
  153. return 1;
  154. }
  155. }
  156. break;
  157. }
  158. case WM_CLOSE:
  159. {
  160. EndDialog(hWndDlg, ERROR_CANCELLED);
  161. return 1;
  162. }
  163. }
  164. return 0;
  165. }
  166. ///////////////////////////////////////////////////////////////////////////////
  167. //
  168. // WelcomeDialog
  169. //
  170. // Display the EULA dialog.
  171. //
  172. ///////////////////////////////////////////////////////////////////////////////
  173. BOOL WelcomeDialog()
  174. {
  175. INT_PTR Status;
  176. Status = DialogBox( NULL,
  177. MAKEINTRESOURCE(IDD_EULA),
  178. 0,
  179. WelcomeDialogProc);
  180. return (Status == ERROR_SUCCESS);
  181. }