{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% osCommerce Product Manager for Windows (oscpmwin). Copyright ©2003-2006 by Mario A. Valdez-Ramirez. You can contact Mario A. Valdez-Ramirez by email at mario@mariovaldez.org or paper mail at Olmos 809, San Nicolas, NL. 66495, Mexico. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} unit regconfig; interface USES Classes; CONST opmC_Def_SaveINIExt = 'ini'; opmC_Def_SaveINIFilename = 'oscpm1.ini'; opmC_Def_SaveINIFilter = '*.ini'; opmC_Def_LoadINIExt = 'ini'; opmC_Def_LoadINIFilename = 'oscpm1.ini'; opmC_Def_LoadINIFilter = '*.ini'; opmC_RKConfig = 'Config'; opmC_RKVisual = 'Windows'; opmC_RKRoot = ''; opmC_RKServers = 'Servers'; opmC_RegistryKey = 'Software\OSCommerce\OSCPMWIN'; PROCEDURE PRReg_WriteSetting (Item, Value, MainRegKey, Subsystem : STRING); FUNCTION FNReg_ReadSetting (Item, DefValue, MainRegKey, Subsystem: STRING): STRING; PROCEDURE PRINI_WriteSetting (Item, Value, IniFileName, Subsystem : STRING); FUNCTION FNINI_ReadSetting (Item, DefValue, IniFileName, Subsystem: STRING): STRING; PROCEDURE PRReg_WritePastList (ItemPrefix, MainRegKey, Subsystem, CurrentItem : STRING; VAR BoxList : TStringList; MaxItems : WORD); PROCEDURE PRReg_ReadPastList (ItemPrefix, MainRegKey, Subsystem : STRING; VAR BoxList : TStringList; MaxItems : WORD); implementation USES Registry, SysUtils, IniFiles; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} FUNCTION FNReg_ReadSetting (Item, DefValue, MainRegKey, Subsystem: STRING): STRING; VAR opm_Reg: TRegIniFile; BEGIN IF (Subsystem = '') THEN opm_Reg := TRegIniFile.Create (MainRegKey) ELSE opm_Reg := TRegIniFile.Create (MainRegKey + '\' + Subsystem); FNReg_ReadSetting := opm_Reg.ReadString ('', Item, DefValue); opm_Reg.Free; END; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} PROCEDURE PRReg_WriteSetting (Item, Value, MainRegKey, Subsystem : STRING); VAR opm_Reg: TRegIniFile; BEGIN IF (Subsystem = '') THEN opm_Reg := TRegIniFile.Create (MainRegKey) ELSE opm_Reg := TRegIniFile.Create (MainRegKey + '\' + Subsystem); opm_Reg.WriteString ('', Item, Value); opm_Reg.Free; END; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} FUNCTION FNINI_ReadSetting (Item, DefValue, IniFileName, Subsystem: STRING): STRING; VAR opm_INI: TIniFile; BEGIN opm_INI := TIniFile.Create (IniFileName); FNIni_ReadSetting := opm_INI.ReadString (Subsystem, Item, DefValue); opm_INI.Free; END; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} PROCEDURE PRINI_WriteSetting (Item, Value, IniFileName, Subsystem : STRING); VAR opm_INI: TIniFile; BEGIN opm_INI := TIniFile.Create (IniFileName); opm_INI.WriteString (Subsystem, Item, Value); opm_INI.Free; END; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} PROCEDURE PRReg_WritePastList (ItemPrefix, MainRegKey, Subsystem, CurrentItem : STRING; VAR BoxList : TStringList; MaxItems : WORD); VAR StrExist : BOOLEAN; CurItem : WORD; BEGIN StrExist := FALSE; FOR CurItem := 2 TO BoxList.Count DO IF (BoxList.Strings[(CurItem - 1)] = CurrentItem) THEN StrExist := TRUE; IF (StrExist = FALSE) THEN BoxList.Insert (1, CurrentItem); FOR CurItem := 2 TO MaxItems DO IF (CurItem <= BoxList.Count) THEN PRReg_WriteSetting (ItemPrefix + INTTOSTR (CurItem - 1), BoxList.Strings[(CurItem - 1)], MainRegKey, Subsystem) ELSE PRReg_WriteSetting (ItemPrefix + INTTOSTR (CurItem - 1), '', MainRegKey, Subsystem); END; {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} PROCEDURE PRReg_ReadPastList (ItemPrefix, MainRegKey, Subsystem : STRING; VAR BoxList : TStringList; MaxItems : WORD); VAR CurItem : WORD; TmpRegVal : STRING; BEGIN BoxList.Add (''); FOR CurItem := 1 TO MaxItems DO BEGIN TmpRegVal := FNReg_ReadSetting (ItemPrefix + INTTOSTR (CurItem), '', MainRegKey, Subsystem); IF (TmpRegVal <> '') THEN BoxList.Add (TmpRegVal); END; END; end.