MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / os_config_write_uint

Function os_config_write_uint

legacy/D3Launch/OS_Config.cpp:229–276  ·  view source on GitHub ↗

Writes an uint32_t to the INI file.

Source from the content-addressed store, hash-verified

227
228// Writes an uint32_t to the INI file.
229void os_config_write_uint(char *section, char *name, uint32_t value) {
230 HKEY hKey = NULL;
231 DWORD dwDisposition;
232 char keyname[1024];
233 LONG lResult;
234
235 if (section) {
236 sprintf(keyname, "Software\\%s\\%s\\%s", szCompanyName, szAppName, section);
237 } else {
238 sprintf(keyname, "Software\\%s\\%s", szCompanyName, szAppName);
239 }
240
241 lResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, // Where to add it
242 keyname, // name of key
243 NULL, // DWORD reserved
244 "", // Object class
245 REG_OPTION_NON_VOLATILE, // Save to disk
246 KEY_ALL_ACCESS, // Allows all changes
247 NULL, // Default security attributes
248 &hKey, // Location to store key
249 &dwDisposition); // Location to store status of key
250
251 if (lResult != ERROR_SUCCESS) {
252 // mprintf( "Error opening registry key '%s'\n", keyname );
253 goto Cleanup;
254 }
255
256 if (!name) {
257 // mprintf( "No variable name passed\n" );
258 goto Cleanup;
259 }
260
261 lResult = RegSetValueEx(hKey, // Handle to key
262 name, // The values name
263 NULL, // DWORD reserved
264 REG_DWORD, // null terminated string
265 (CONST BYTE *)&value, // value to set
266 4); // How many bytes to set
267
268 if (lResult != ERROR_SUCCESS) {
269 // mprintf( "Error writing registry key '%s'\n", name );
270 goto Cleanup;
271 }
272
273Cleanup:
274 if (hKey)
275 RegCloseKey(hKey);
276}
277
278// Reads a string from the INI file. If default is passed,
279// and the string isn't found, returns ptr to default otherwise

Callers 12

OnOKMethod · 0.85
OnYesMethod · 0.85
OnInitDialogMethod · 0.85
OnOKMethod · 0.85
OnOKMethod · 0.85
OnOKMethod · 0.85
OnOKMethod · 0.85
OnOKMethod · 0.85
OnBtnSetupMethod · 0.85
OnBtnPlayMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected