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