Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
wolSetup.cpp
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(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
19// FILE: wolSetup.cpp //////////////////////////////////////////////////////
20// Defines the entry point for the application.
21// Author: Matthew D. Campbell, December 2001
22
23#ifndef WIN32_LEAN_AND_MEAN
24#define WIN32_LEAN_AND_MEAN
25#endif
26#include <windows.h>
27#include <stdio.h>
28#include <stdlib.h>
29
30#include "resource.h"
31#include "wolSetup.h"
32#include "verchk.h"
33
34void registerDLL(const char *dllName)
35{
36 HINSTANCE hLib = LoadLibrary(dllName);
37 FARPROC lpDllEntryPoint;
38
39 if (hLib < (HINSTANCE)HINSTANCE_ERROR)
40 {
41 return;
42 }
43
44 // Find the entry point.
45 (FARPROC&)lpDllEntryPoint = GetProcAddress(hLib,
46 "DllRegisterServer");
47 if (lpDllEntryPoint != NULL)
48 (*lpDllEntryPoint)();
49 else
50 ;//unable to locate entry point
51}
52
53
54
55HINSTANCE g_hInst = NULL;
56
57LRESULT CALLBACK MainDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
58
59int APIENTRY WinMain(HINSTANCE hInstance,
60 HINSTANCE hPrevInstance,
61 LPSTR lpCmdLine,
62 int nCmdShow)
63{
64 g_hInst = hInstance;
65
67
68 DialogBox(g_hInst, (LPCTSTR)IDD_MAINBOX, NULL, (DLGPROC)MainDialogProc);
69
70 return 0;
71}
72
73
74// Mesage handler for generals setup box.
75LRESULT CALLBACK GeneralsSetupDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
76{
77 switch (message)
78 {
79 case WM_INITDIALOG:
80 {
81 SetDlgItemText(hDlg, IDC_EDIT_PATH, g_generalsFilename);
82 SetDlgItemText(hDlg, IDC_EDIT_SERIAL, g_generalsSerial);
83 return TRUE;
84 }
85
86 case WM_COMMAND:
87 switch(LOWORD(wParam))
88 {
89 case IDOK:
90 {
91 char genPath[_MAX_PATH], genSerial[1024];
92 GetDlgItemText(hDlg, IDC_EDIT_PATH, genPath, _MAX_PATH);
93 GetDlgItemText(hDlg, IDC_EDIT_SERIAL, genSerial, 1024);
94 setupGenerals( genPath, genSerial );
95 EndDialog(hDlg, LOWORD(wParam));
96 return TRUE;
97 }
98
99 case IDCANCEL:
100 {
101 EndDialog(hDlg, LOWORD(wParam));
102 return TRUE;
103 }
104 }
105 break;
106 }
107 return FALSE;
108}
109
110void updateDisplay(HWND hDlg)
111{
114 {
115 char buf[200];
116 sprintf(buf, "%d.%d (%s)", MAJOR(g_wolapiRealVersion), MINOR(g_wolapiRealVersion), g_wolapiRealFilename);
117 SetDlgItemText(hDlg, IDC_TEXT_WOLVER, buf);
118 }
119 else
120 {
121 SetDlgItemText(hDlg, IDC_TEXT_WOLVER, "Not installed");
122 }
123 SetDlgItemText(hDlg, IDC_TEXT_WOLDIR, g_wolapiRegFilename);
124 SetDlgItemText(hDlg, IDC_TEXT_GENERALSDIR, g_generalsFilename);
125}
126
127// Mesage handler for main dialog box.
128LRESULT CALLBACK MainDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
129{
130 switch (message)
131 {
132 case WM_INITDIALOG:
133 {
134 updateDisplay(hDlg);
135 return TRUE;
136 }
137
138 case WM_COMMAND:
139 switch(LOWORD(wParam))
140 {
141 case IDOK:
142 case IDCANCEL:
143 {
144 EndDialog(hDlg, LOWORD(wParam));
145 return TRUE;
146 }
148 {
149 DialogBox(g_hInst, (LPCTSTR)IDD_GENERALSSETUPBOX, hDlg, (DLGPROC)GeneralsSetupDialogProc);
150 updateDisplay(hDlg);
151 break;
152 }
154 {
155 if (MessageBox(hDlg, "Are you sure you want to delete Generals registry entries?", "Warning!", MB_OKCANCEL) == IDOK)
156 {
157 MessageBox(hDlg, "Oops! Can't do that yet!", "Unimplemented", MB_OK);
158 updateDisplay(hDlg);
159 }
160 break;
161 }
162 case IDC_DEBUG_WOLAPI:
163 {
165 {
166 if (MessageBox(hDlg, "Are you sure you want to overwrite installed WOLAPI?", "Warning!", MB_OKCANCEL) == IDOK)
167 {
168 registerDLL("woldbg.dll");
169 updateDisplay(hDlg);
170 }
171 }
172 else
173 {
174 DialogBox(g_hInst, (LPCTSTR)IDD_GENERALSSETUPBOX, hDlg, (DLGPROC)MainDialogProc);
175 }
176 break;
177 }
179 {
181 {
182 if (MessageBox(hDlg, "Are you sure you want to overwrite installed WOLAPI?", "Warning!", MB_OKCANCEL) == IDOK)
183 {
184 registerDLL("wolapi.dll");
185 updateDisplay(hDlg);
186 }
187 }
188 else
189 {
190 DialogBox(g_hInst, (LPCTSTR)IDD_GENERALSSETUPBOX, hDlg, (DLGPROC)MainDialogProc);
191 updateDisplay(hDlg);
192 }
193 break;
194 }
196 {
198 {
199 MessageBox(hDlg, "Oops! Can't do that yet!", "Unimplemented", MB_OK);
200 updateDisplay(hDlg);
201 }
202 break;
203 }
204 }
205 break;
206 }
207 return FALSE;
208}
209
210
211
#define NULL
Definition BaseType.h:92
#define TRUE
Definition BaseType.h:109
#define FALSE
Definition BaseType.h:113
unsigned int UINT
Definition bittype.h:63
#define IDD_MAINBOX
Definition resource.h:27
#define IDC_EDIT_PATH
Definition resource.h:39
#define IDC_TEXT_WOLVER
Definition resource.h:38
#define IDC_TEXT_WOLDIR
Definition resource.h:36
#define IDC_TEXT_GENERALSDIR
Definition resource.h:37
#define IDC_RELEASE_WOLAPI
Definition resource.h:32
#define IDC_DEBUG_WOLAPI
Definition resource.h:31
#define IDC_UNINSTALL_GENERALS
Definition resource.h:35
#define IDC_SETUP_GENERALS
Definition resource.h:34
#define IDD_GENERALSSETUPBOX
Definition resource.h:28
#define IDC_UNINSTALL_WOLAPI
Definition resource.h:33
#define IDC_EDIT_SERIAL
Definition resource.h:40
char g_generalsSerial[1024]
Definition wolInit.cpp:45
unsigned long g_wolapiRealVersion
Definition wolInit.cpp:40
void setupGenerals(const char *genPath, const char *genSerial)
Definition wolInit.cpp:140
void checkInstalledWolapiVersion(void)
Definition wolInit.cpp:191
char g_wolapiRegFilename[MAX_PATH]
Definition wolInit.cpp:42
char g_wolapiRealFilename[MAX_PATH]
Definition wolInit.cpp:43
char g_generalsFilename[MAX_PATH]
Definition wolInit.cpp:44
bool g_wolapiInstalled
Definition wolInit.cpp:41
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
Definition wolSetup.cpp:59
void updateDisplay(HWND hDlg)
Definition wolSetup.cpp:110
LRESULT CALLBACK GeneralsSetupDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition wolSetup.cpp:75
void registerDLL(const char *dllName)
Definition wolSetup.cpp:34
HINSTANCE g_hInst
Definition wolSetup.cpp:55
LRESULT CALLBACK MainDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition wolSetup.cpp:128