]> Shamusworld >> Repos - ttedit/blob - src/registry.cpp
Colorized Makefile. Whee!
[ttedit] / src / registry.cpp
1 //
2 // REGISTRY.CPP - Win32 support file
3 // by James L. Hammons
4 // (C) 2002 Underground Software
5 //
6 //   JLH = James Hammons <jlhamm@acm.org>
7 //
8 // Who  When        What
9 // ---  ----------  ------------------------------------------------------------
10 // JLH  05/16/2002  Created this file
11 // JLH  12/10/2002  Updated InitINIFile to take a parameter so that you can open
12 //                  an .INI file that doesn't belong to the current module
13 //
14 // STILL TO BE DONE:
15 //
16 // - Convert to wxWidgets...
17 //
18
19 #warning This file not yet converted to wxWidgets!!!
20
21 #if 0
22 #include <windows.h>
23 #include "registry.h"
24
25 // Local data
26
27 static char INIPath[MAX_PATH];
28 static char str[4096];
29
30 //
31 // Initialize the application .INI file
32 // Returns TRUE if succesful, FALSE otherwise...
33 //
34 void InitINIFile(char * path/*= NULL*/)
35 {
36         if (!GetModuleFileName(NULL, INIPath, MAX_PATH))
37                 return;
38
39         if (path == NULL)
40         {
41                 int len = lstrlen(INIPath);
42                 lstrcpy(INIPath + len - 4, ".ini");
43         }
44         else
45         {
46                 for(int i=lstrlen(INIPath); i>=0; i--)
47                 {
48                         if (INIPath[i] == '\\')
49                         {
50                                 lstrcpy(INIPath + i + 1, path);
51                                 break;
52                         }
53                 }
54         }
55 }
56
57 //
58 // Write an int value to our .INI file
59 //
60 void SetINIInt(char * section, char * entry, int32 value)
61 {
62         const char fmtStr[] = "%d";
63         char strVal[20];
64
65         wsprintf(strVal, fmtStr, value);
66         WritePrivateProfileString(section, entry, strVal, INIPath);
67 }
68
69 //
70 // Write a string value to our .INI file
71 //
72 void SetINIString(char * section, char * entry, char * value)
73 {
74         WritePrivateProfileString(section, entry, value, INIPath);
75 }
76
77 //
78 // Get an int value from our .INI file
79 //
80 int32 GetINIInt(char * section, char * entry, int32 _default)
81 {
82         return GetPrivateProfileInt(section, entry, _default, INIPath);
83 }
84
85 //
86 // Get a string value from our .INI file
87 //
88 const char * GetINIString(char * section, char * entry, char * _default)
89 {
90         GetPrivateProfileString(section, entry, _default, str, 4096, INIPath);
91
92         return str;
93 }
94 #endif