[80] | 1 | /********************************************************************** <BR>
|
---|
| 2 | This file is part of Crack dot Com's free source code release of
|
---|
| 3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
| 4 | information about compiling & licensing issues visit this URL</a>
|
---|
| 5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
| 6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
| 7 | ***********************************************************************/
|
---|
| 8 |
|
---|
| 9 | #include <windows.h>
|
---|
| 10 | #include "app/registry.hh"
|
---|
| 11 |
|
---|
| 12 |
|
---|
| 13 | i4_bool i4_get_registry(i4_registry_type type,
|
---|
| 14 | char *path,
|
---|
| 15 | char *key_name,
|
---|
| 16 | char *buffer, int buf_length)
|
---|
| 17 | {
|
---|
| 18 | HKEY key;
|
---|
| 19 |
|
---|
| 20 | if (RegOpenKeyEx(type==I4_REGISTRY_MACHINE ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
|
---|
| 21 | path,
|
---|
| 22 | 0,
|
---|
| 23 | KEY_READ,
|
---|
| 24 | &key)==ERROR_SUCCESS)
|
---|
| 25 | {
|
---|
| 26 | for (int i=0; 1; i++)
|
---|
| 27 | {
|
---|
| 28 | char name[256];
|
---|
| 29 | DWORD name_size=256, type;
|
---|
| 30 | DWORD data_size=buf_length;
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 |
|
---|
| 34 | if (RegEnumValue(key, i, name, &name_size, 0,
|
---|
| 35 | &type,
|
---|
| 36 | (LPBYTE)buffer,
|
---|
| 37 | &data_size)==ERROR_SUCCESS)
|
---|
| 38 | {
|
---|
| 39 | if (strcmp(name, key_name)==0)
|
---|
| 40 | {
|
---|
| 41 | RegCloseKey(key);
|
---|
| 42 | return i4_T;
|
---|
| 43 | }
|
---|
| 44 | }
|
---|
| 45 | else
|
---|
| 46 | {
|
---|
| 47 | RegCloseKey(key);
|
---|
| 48 | return i4_F;
|
---|
| 49 | }
|
---|
| 50 | }
|
---|
| 51 | }
|
---|
| 52 | return i4_F;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 | i4_bool i4_set_registry(i4_registry_type type,
|
---|
| 57 | char *path,
|
---|
| 58 | char *key_name,
|
---|
| 59 | char *buffer)
|
---|
| 60 | {
|
---|
| 61 | HKEY key;
|
---|
| 62 |
|
---|
| 63 | if (RegCreateKey(type==I4_REGISTRY_MACHINE ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
|
---|
| 64 | path,
|
---|
| 65 | &key)==ERROR_SUCCESS)
|
---|
| 66 | {
|
---|
| 67 | RegSetValueEx(key, key_name, 0, REG_SZ, (w8 *)buffer, strlen(buffer)+1);
|
---|
| 68 | RegCloseKey(key);
|
---|
| 69 | return i4_T;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | return i4_F;
|
---|
| 73 | }
|
---|
| 74 |
|
---|