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

Function os_config_read_string

legacy/D3Launch/OS_Config.cpp:286–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284static char tmp_string_data[1024];
285
286char *os_config_read_string(char *section, char *name, char *default_value) {
287 HKEY hKey = NULL;
288 DWORD dwType, dwLen;
289 char keyname[1024];
290 LONG lResult;
291
292 if (section) {
293 sprintf(keyname, "Software\\%s\\%s\\%s", szCompanyName, szAppName, section);
294 } else {
295 sprintf(keyname, "Software\\%s\\%s", szCompanyName, szAppName);
296 }
297
298 lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, // Where it is
299 keyname, // name of key
300 NULL, // DWORD reserved
301 KEY_QUERY_VALUE, // Allows all changes
302 &hKey); // Location to store key
303
304 if (lResult != ERROR_SUCCESS) {
305 // mprintf( "Error opening registry key '%s'\n", keyname );
306 goto Cleanup;
307 }
308
309 if (!name) {
310 // mprintf( "No variable name passed\n" );
311 goto Cleanup;
312 }
313
314 dwLen = 1024;
315 lResult = RegQueryValueEx(hKey, // Handle to key
316 name, // The values name
317 NULL, // DWORD reserved
318 &dwType, // What kind it is
319 (uint8_t *)&tmp_string_data, // value to set
320 &dwLen); // How many bytes to set
321
322 if (lResult != ERROR_SUCCESS) {
323 // mprintf( "Error reading registry key '%s'\n", name );
324 goto Cleanup;
325 }
326
327 default_value = tmp_string_data;
328
329Cleanup:
330 if (hKey)
331 RegCloseKey(hKey);
332
333 return default_value;
334}
335
336static char tmp_string_data_ex[1024];
337

Callers 6

OnBtnSpeedDetectMethod · 0.85
OnInitDialogMethod · 0.85
OnInitDialogMethod · 0.85
OnInitDialogMethod · 0.85
OnBtnPlayMethod · 0.85
OnInitDialogMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected