Source code of file oscpmwin_v0.4.1.723/regconfig.pas from the
osCommerce Product Manager for Windows.
0000: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001: osCommerce Product Manager for Windows (oscpmwin).
0002: Copyright �2003-2006 by Mario A. Valdez-Ramirez.
0003:
0004: You can contact Mario A. Valdez-Ramirez
0005: by email at mario@mariovaldez.org or paper mail at
0006: Olmos 809, San Nicolas, NL. 66495, Mexico.
0007:
0008: This program is free software; you can redistribute it and/or modify
0009: it under the terms of the GNU General Public License as published by
0010: the Free Software Foundation; either version 2 of the License, or (at
0011: your option) any later version.
0012:
0013: This program is distributed in the hope that it will be useful, but
0014: WITHOUT ANY WARRANTY; without even the implied warranty of
0015: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0016: General Public License for more details.
0017:
0018: You should have received a copy of the GNU General Public License
0019: along with this program; if not, write to the Free Software
0020: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0021: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0022: unit regconfig;
0023:
0024: interface
0025:
0026: USES Classes;
0027:
0028: CONST
0029: opmC_Def_SaveINIExt = 'ini';
0030: opmC_Def_SaveINIFilename = 'oscpm1.ini';
0031: opmC_Def_SaveINIFilter = '*.ini';
0032: opmC_Def_LoadINIExt = 'ini';
0033: opmC_Def_LoadINIFilename = 'oscpm1.ini';
0034: opmC_Def_LoadINIFilter = '*.ini';
0035: opmC_RKConfig = 'Config';
0036: opmC_RKVisual = 'Windows';
0037: opmC_RKRoot = '';
0038: opmC_RKServers = 'Servers';
0039: opmC_RegistryKey = 'Software\OSCommerce\OSCPMWIN';
0040:
0041:
0042: PROCEDURE PRReg_WriteSetting (Item, Value, MainRegKey, Subsystem : STRING);
0043: FUNCTION FNReg_ReadSetting (Item, DefValue, MainRegKey, Subsystem: STRING): STRING;
0044: PROCEDURE PRINI_WriteSetting (Item, Value, IniFileName, Subsystem : STRING);
0045: FUNCTION FNINI_ReadSetting (Item, DefValue, IniFileName, Subsystem: STRING): STRING;
0046: PROCEDURE PRReg_WritePastList (ItemPrefix, MainRegKey, Subsystem, CurrentItem : STRING; VAR BoxList : TStringList; MaxItems : WORD);
0047: PROCEDURE PRReg_ReadPastList (ItemPrefix, MainRegKey, Subsystem : STRING; VAR BoxList : TStringList; MaxItems : WORD);
0048:
0049:
0050: implementation
0051:
0052: USES Registry, SysUtils, IniFiles;
0053:
0054:
0055: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0056: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0057: FUNCTION FNReg_ReadSetting (Item, DefValue, MainRegKey, Subsystem: STRING): STRING;
0058: VAR
0059: opm_Reg: TRegIniFile;
0060: BEGIN
0061: IF (Subsystem = '') THEN
0062: opm_Reg := TRegIniFile.Create (MainRegKey)
0063: ELSE
0064: opm_Reg := TRegIniFile.Create (MainRegKey + '\' + Subsystem);
0065: FNReg_ReadSetting := opm_Reg.ReadString ('', Item, DefValue);
0066: opm_Reg.Free;
0067: END;
0068:
0069:
0070: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0071: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0072: PROCEDURE PRReg_WriteSetting (Item, Value, MainRegKey, Subsystem : STRING);
0073: VAR
0074: opm_Reg: TRegIniFile;
0075: BEGIN
0076: IF (Subsystem = '') THEN
0077: opm_Reg := TRegIniFile.Create (MainRegKey)
0078: ELSE
0079: opm_Reg := TRegIniFile.Create (MainRegKey + '\' + Subsystem);
0080: opm_Reg.WriteString ('', Item, Value);
0081: opm_Reg.Free;
0082: END;
0083:
0084:
0085: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0086: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0087: FUNCTION FNINI_ReadSetting (Item, DefValue, IniFileName, Subsystem: STRING): STRING;
0088: VAR
0089: opm_INI: TIniFile;
0090: BEGIN
0091: opm_INI := TIniFile.Create (IniFileName);
0092: FNIni_ReadSetting := opm_INI.ReadString (Subsystem, Item, DefValue);
0093: opm_INI.Free;
0094: END;
0095:
0096:
0097: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0098: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0099: PROCEDURE PRINI_WriteSetting (Item, Value, IniFileName, Subsystem : STRING);
0100: VAR
0101: opm_INI: TIniFile;
0102: BEGIN
0103: opm_INI := TIniFile.Create (IniFileName);
0104: opm_INI.WriteString (Subsystem, Item, Value);
0105: opm_INI.Free;
0106: END;
0107:
0108:
0109: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0110: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0111: PROCEDURE PRReg_WritePastList (ItemPrefix, MainRegKey, Subsystem, CurrentItem : STRING; VAR BoxList : TStringList; MaxItems : WORD);
0112: VAR
0113: StrExist : BOOLEAN;
0114: CurItem : WORD;
0115: BEGIN
0116: StrExist := FALSE;
0117: FOR CurItem := 2 TO BoxList.Count DO
0118: IF (BoxList.Strings[(CurItem - 1)] = CurrentItem) THEN StrExist := TRUE;
0119: IF (StrExist = FALSE) THEN BoxList.Insert (1, CurrentItem);
0120:
0121: FOR CurItem := 2 TO MaxItems DO
0122: IF (CurItem <= BoxList.Count) THEN
0123: PRReg_WriteSetting (ItemPrefix + INTTOSTR (CurItem - 1), BoxList.Strings[(CurItem - 1)], MainRegKey, Subsystem)
0124: ELSE PRReg_WriteSetting (ItemPrefix + INTTOSTR (CurItem - 1), '', MainRegKey, Subsystem);
0125: END;
0126:
0127:
0128: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0129: {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0130: PROCEDURE PRReg_ReadPastList (ItemPrefix, MainRegKey, Subsystem : STRING; VAR BoxList : TStringList; MaxItems : WORD);
0131: VAR
0132: CurItem : WORD;
0133: TmpRegVal : STRING;
0134: BEGIN
0135: BoxList.Add ('');
0136: FOR CurItem := 1 TO MaxItems DO
0137: BEGIN
0138: TmpRegVal := FNReg_ReadSetting (ItemPrefix + INTTOSTR (CurItem), '', MainRegKey, Subsystem);
0139: IF (TmpRegVal <> '') THEN BoxList.Add (TmpRegVal);
0140: END;
0141: END;
0142:
0143:
0144:
0145:
0146:
0147: end.