2 // REGISTRY.CPP - Win32 support file
\r
3 // by James L. Hammons
\r
4 // (C) 2002 Underground Software
\r
6 // JLH = James Hammons <jlhamm@acm.org>
\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
14 // STILL TO BE DONE:
\r
16 // - Convert to wxWidgets...
\r
19 #warning This file not yet converted to wxWidgets!!!
\r
22 #include <windows.h>
\r
23 #include "registry.h"
\r
27 static char INIPath[MAX_PATH];
\r
28 static char str[4096];
\r
31 // Initialize the application .INI file
\r
32 // Returns TRUE if succesful, FALSE otherwise...
\r
34 void InitINIFile(char * path/*= NULL*/)
\r
36 if (!GetModuleFileName(NULL, INIPath, MAX_PATH))
\r
41 int len = lstrlen(INIPath);
\r
42 lstrcpy(INIPath + len - 4, ".ini");
\r
46 for(int i=lstrlen(INIPath); i>=0; i--)
\r
48 if (INIPath[i] == '\\')
\r
50 lstrcpy(INIPath + i + 1, path);
\r
58 // Write an int value to our .INI file
\r
60 void SetINIInt(char * section, char * entry, int32 value)
\r
62 const char fmtStr[] = "%d";
\r
65 wsprintf(strVal, fmtStr, value);
\r
66 WritePrivateProfileString(section, entry, strVal, INIPath);
\r
70 // Write a string value to our .INI file
\r
72 void SetINIString(char * section, char * entry, char * value)
\r
74 WritePrivateProfileString(section, entry, value, INIPath);
\r
78 // Get an int value from our .INI file
\r
80 int32 GetINIInt(char * section, char * entry, int32 _default)
\r
82 return GetPrivateProfileInt(section, entry, _default, INIPath);
\r
86 // Get a string value from our .INI file
\r
88 const char * GetINIString(char * section, char * entry, char * _default)
\r
90 GetPrivateProfileString(section, entry, _default, str, 4096, INIPath);
\r