source: golgotha/src/test/g_install/inst_win32.cc

Last change on this file was 80, checked in by Sam Hocevar, 13 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 2.5 KB
Line 
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
13int i4_disk_free_space(char *path)
14{
15  return 80*1024*1024;
16}
17
18// int freespace(char *path)
19// {
20// `  i4_filename_struct fn;
21//   i4_split_path(path, fn);
22
23//   WORD sects_per_cluster, bytes_per_sector,
24//     num_free_clusters, t_clusters;
25 
26//   if (GetDiskFreeSpace(fn.path, &sects_per_cluster,
27//                        &bytes_per_sector,
28//                        &num_free_clusters,
29//                        &t_clusters))
30//   {
31//     return num_free_clusters * sects_per_cluster * bytes_per_sector;
32//   }
33//   else
34
35
36
37i4_bool i4_get_registry(i4_registry_type type,
38                        char *path,
39                        char *key_name,
40                        char *buffer, int buf_length)
41{
42  HKEY key;
43
44  if (RegOpenKeyEx(type==I4_REGISTRY_MACHINE ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
45                   path,
46                   0,
47                   KEY_READ,
48                   &key)==ERROR_SUCCESS)
49  {
50    for (int i=0; 1; i++)
51    {
52      char name[256];
53      DWORD name_size=256, type;
54      DWORD data_size=buf_length;
55     
56
57
58      if (RegEnumValue(key, i, name, &name_size, 0,
59                     &type,
60                     (LPBYTE)buffer,
61                     &data_size)==ERROR_SUCCESS)
62      {
63        if (strcmp(name, key_name)==0)
64        {
65          RegCloseKey(key);
66          return i4_T;
67        }
68      }
69      else
70      {
71        RegCloseKey(key);
72        return i4_F;
73      }
74    }
75  }
76  return i4_F;
77}
78
79
80i4_bool i4_set_registry(i4_registry_type type,
81                        char *path,
82                        char *key_name,
83                        char *buffer)
84{
85  HKEY key;
86
87  if (RegCreateKey(type==I4_REGISTRY_MACHINE ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
88                 path,
89                 &key)==ERROR_SUCCESS)
90  {
91    RegSetValueEx(key, key_name, 0, REG_SZ, (w8 *)buffer, strlen(buffer)+1);
92    RegCloseKey(key);
93    return i4_T;
94  }
95 
96  return i4_F;
97}
98
Note: See TracBrowser for help on using the repository browser.