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