wolSetup.cpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. // FILE: wolSetup.cpp //////////////////////////////////////////////////////
  19. // Defines the entry point for the application.
  20. // Author: Matthew D. Campbell, December 2001
  21. #ifndef WIN32_LEAN_AND_MEAN
  22. #define WIN32_LEAN_AND_MEAN
  23. #endif
  24. #include <windows.h>
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include "resource.h"
  28. #include "wolSetup.h"
  29. #include "verchk.h"
  30. void registerDLL(const char *dllName)
  31. {
  32. HINSTANCE hLib = LoadLibrary(dllName);
  33. FARPROC lpDllEntryPoint;
  34. if (hLib < (HINSTANCE)HINSTANCE_ERROR)
  35. {
  36. return;
  37. }
  38. // Find the entry point.
  39. (FARPROC&)lpDllEntryPoint = GetProcAddress(hLib,
  40. "DllRegisterServer");
  41. if (lpDllEntryPoint != NULL)
  42. (*lpDllEntryPoint)();
  43. else
  44. ;//unable to locate entry point
  45. }
  46. HINSTANCE g_hInst = NULL;
  47. LRESULT CALLBACK MainDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  48. int APIENTRY WinMain(HINSTANCE hInstance,
  49. HINSTANCE hPrevInstance,
  50. LPSTR lpCmdLine,
  51. int nCmdShow)
  52. {
  53. g_hInst = hInstance;
  54. checkInstalledWolapiVersion();
  55. DialogBox(g_hInst, (LPCTSTR)IDD_MAINBOX, NULL, (DLGPROC)MainDialogProc);
  56. return 0;
  57. }
  58. // Mesage handler for generals setup box.
  59. LRESULT CALLBACK GeneralsSetupDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  60. {
  61. switch (message)
  62. {
  63. case WM_INITDIALOG:
  64. {
  65. SetDlgItemText(hDlg, IDC_EDIT_PATH, g_generalsFilename);
  66. SetDlgItemText(hDlg, IDC_EDIT_SERIAL, g_generalsSerial);
  67. return TRUE;
  68. }
  69. case WM_COMMAND:
  70. switch(LOWORD(wParam))
  71. {
  72. case IDOK:
  73. {
  74. char genPath[_MAX_PATH], genSerial[1024];
  75. GetDlgItemText(hDlg, IDC_EDIT_PATH, genPath, _MAX_PATH);
  76. GetDlgItemText(hDlg, IDC_EDIT_SERIAL, genSerial, 1024);
  77. setupGenerals( genPath, genSerial );
  78. EndDialog(hDlg, LOWORD(wParam));
  79. return TRUE;
  80. }
  81. case IDCANCEL:
  82. {
  83. EndDialog(hDlg, LOWORD(wParam));
  84. return TRUE;
  85. }
  86. }
  87. break;
  88. }
  89. return FALSE;
  90. }
  91. void updateDisplay(HWND hDlg)
  92. {
  93. checkInstalledWolapiVersion();
  94. if (g_wolapiInstalled)
  95. {
  96. char buf[200];
  97. sprintf(buf, "%d.%d (%s)", MAJOR(g_wolapiRealVersion), MINOR(g_wolapiRealVersion), g_wolapiRealFilename);
  98. SetDlgItemText(hDlg, IDC_TEXT_WOLVER, buf);
  99. }
  100. else
  101. {
  102. SetDlgItemText(hDlg, IDC_TEXT_WOLVER, "Not installed");
  103. }
  104. SetDlgItemText(hDlg, IDC_TEXT_WOLDIR, g_wolapiRegFilename);
  105. SetDlgItemText(hDlg, IDC_TEXT_GENERALSDIR, g_generalsFilename);
  106. }
  107. // Mesage handler for main dialog box.
  108. LRESULT CALLBACK MainDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  109. {
  110. switch (message)
  111. {
  112. case WM_INITDIALOG:
  113. {
  114. updateDisplay(hDlg);
  115. return TRUE;
  116. }
  117. case WM_COMMAND:
  118. switch(LOWORD(wParam))
  119. {
  120. case IDOK:
  121. case IDCANCEL:
  122. {
  123. EndDialog(hDlg, LOWORD(wParam));
  124. return TRUE;
  125. }
  126. case IDC_SETUP_GENERALS:
  127. {
  128. DialogBox(g_hInst, (LPCTSTR)IDD_GENERALSSETUPBOX, hDlg, (DLGPROC)GeneralsSetupDialogProc);
  129. updateDisplay(hDlg);
  130. break;
  131. }
  132. case IDC_UNINSTALL_GENERALS:
  133. {
  134. if (MessageBox(hDlg, "Are you sure you want to delete Generals registry entries?", "Warning!", MB_OKCANCEL) == IDOK)
  135. {
  136. MessageBox(hDlg, "Oops! Can't do that yet!", "Unimplemented", MB_OK);
  137. updateDisplay(hDlg);
  138. }
  139. break;
  140. }
  141. case IDC_DEBUG_WOLAPI:
  142. {
  143. if (g_wolapiInstalled)
  144. {
  145. if (MessageBox(hDlg, "Are you sure you want to overwrite installed WOLAPI?", "Warning!", MB_OKCANCEL) == IDOK)
  146. {
  147. registerDLL("woldbg.dll");
  148. updateDisplay(hDlg);
  149. }
  150. }
  151. else
  152. {
  153. DialogBox(g_hInst, (LPCTSTR)IDD_GENERALSSETUPBOX, hDlg, (DLGPROC)MainDialogProc);
  154. }
  155. break;
  156. }
  157. case IDC_RELEASE_WOLAPI:
  158. {
  159. if (g_wolapiInstalled)
  160. {
  161. if (MessageBox(hDlg, "Are you sure you want to overwrite installed WOLAPI?", "Warning!", MB_OKCANCEL) == IDOK)
  162. {
  163. registerDLL("wolapi.dll");
  164. updateDisplay(hDlg);
  165. }
  166. }
  167. else
  168. {
  169. DialogBox(g_hInst, (LPCTSTR)IDD_GENERALSSETUPBOX, hDlg, (DLGPROC)MainDialogProc);
  170. updateDisplay(hDlg);
  171. }
  172. break;
  173. }
  174. case IDC_UNINSTALL_WOLAPI:
  175. {
  176. if (g_wolapiInstalled)
  177. {
  178. MessageBox(hDlg, "Oops! Can't do that yet!", "Unimplemented", MB_OK);
  179. updateDisplay(hDlg);
  180. }
  181. break;
  182. }
  183. }
  184. break;
  185. }
  186. return FALSE;
  187. }