Bruce
06-06-2004, 03:16 PM
Using the code below I am attempting to keep the end user from messing around with the system clock. When the system clock is changed, The area in RED does show up but does not exit as it should. It continues through to the code in Blue.
What needs to change?
B.T.W. This code is not self-reliant (stand alone), it pulls from other pages.
if Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "Software\\741993\\Data") then
todays_date = String.ToNumber(System.GetDate(DATE_FMT_JULIAN));
Crypto.Base64DecodeFromString(Registry.GetValue(HK EY_LOCAL_MACHINE, "Software\\741993\\Data", "cj", false), _TempFolder.."741993.tmp");
current_cj = String.ToNumber(TextFile.ReadToString(_TempFolder. ."741993.tmp"));
File.Delete(_TempFolder.."741993.tmp",false, true,false,nil);
if (todays_date < current_cj) then
--System clock has been turned back before the initial install date
result = Dialog.Message("ERROR", "There has been an error with your systems clock. This program will now exit.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
File.Run("DATA\\1993ICU2.dll", "", "", SW_SHOWNORMAL, false);
Application.Exit();
else
current_cj = String.ToNumber(System.GetDate(DATE_FMT_JULIAN));
TextFile.WriteFromString(_TempFolder.."741993.tmp", current_cj , false);
encdate = Crypto.Base64EncodeToString(_TempFolder.."741993.tmp", 0);
File.Delete(_TempFolder.."741993.tmp",false, true,false,nil);
Registry.SetValue(HKEY_LOCAL_MACHINE, "Software\\741993\\Data", "cj",encdate, REG_SZ);
end
Crypto.Base64DecodeFromString(Registry.GetValue(HK EY_LOCAL_MACHINE, "Software\\741993\\Data", "sj", false), _TempFolder.."741993.tmp");
start_sj = String.ToNumber(TextFile.ReadToString(_TempFolder. ."741993.tmp"));
File.Delete(_TempFolder.."741993.tmp",false, true,false,nil);
if (current_cj >= (start_sj + 365)) then
-- product has expired
result = Dialog.Message("Notice", "Your installation of this product has expired. This program will now exit.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
File.Run("DATA\\1993ICU2.dll", "", "", SW_SHOWNORMAL, false);
Application.Exit();
end
else
if File.DoesExist(_SystemFolder .. "\\741993.log") then
encdate = Crypto.Base64EncodeToString(_SystemFolder.."\\741993.log", 0);
Registry.CreateKey(HKEY_LOCAL_MACHINE,"Software\\741993\\Data");
Registry.SetValue(HKEY_LOCAL_MACHINE, "Software\\741993\\Data", "sj",encdate, REG_SZ);
TextFile.WriteFromString(_TempFolder.."741993.tmp", System.GetDate(DATE_FMT_JULIAN), false);
encdate = Crypto.Base64EncodeToString(_TempFolder.."741993.tmp", 0);
File.Delete(_TempFolder.."741993.tmp",false, true,false,nil);
Registry.SetValue(HKEY_LOCAL_MACHINE, "Software\\741993\\Data", "cj",encdate, REG_SZ);
else
TextFile.WriteFromString(_SystemFolder.."\\741993.log", System.GetDate(DATE_FMT_JULIAN), false);
encdate = Crypto.Base64EncodeToString(_SystemFolder.."\\741993.log", 0);
Registry.CreateKey(HKEY_LOCAL_MACHINE,"Software\\741993\\Data");
Registry.SetValue(HKEY_LOCAL_MACHINE, "Software\\741993\\Data", "sj",encdate, REG_SZ);
Registry.SetValue(HKEY_LOCAL_MACHINE, "Software\\741993\\Data", "cj",encdate, REG_SZ);
end
end
What needs to change?
B.T.W. This code is not self-reliant (stand alone), it pulls from other pages.
if Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "Software\\741993\\Data") then
todays_date = String.ToNumber(System.GetDate(DATE_FMT_JULIAN));
Crypto.Base64DecodeFromString(Registry.GetValue(HK EY_LOCAL_MACHINE, "Software\\741993\\Data", "cj", false), _TempFolder.."741993.tmp");
current_cj = String.ToNumber(TextFile.ReadToString(_TempFolder. ."741993.tmp"));
File.Delete(_TempFolder.."741993.tmp",false, true,false,nil);
if (todays_date < current_cj) then
--System clock has been turned back before the initial install date
result = Dialog.Message("ERROR", "There has been an error with your systems clock. This program will now exit.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
File.Run("DATA\\1993ICU2.dll", "", "", SW_SHOWNORMAL, false);
Application.Exit();
else
current_cj = String.ToNumber(System.GetDate(DATE_FMT_JULIAN));
TextFile.WriteFromString(_TempFolder.."741993.tmp", current_cj , false);
encdate = Crypto.Base64EncodeToString(_TempFolder.."741993.tmp", 0);
File.Delete(_TempFolder.."741993.tmp",false, true,false,nil);
Registry.SetValue(HKEY_LOCAL_MACHINE, "Software\\741993\\Data", "cj",encdate, REG_SZ);
end
Crypto.Base64DecodeFromString(Registry.GetValue(HK EY_LOCAL_MACHINE, "Software\\741993\\Data", "sj", false), _TempFolder.."741993.tmp");
start_sj = String.ToNumber(TextFile.ReadToString(_TempFolder. ."741993.tmp"));
File.Delete(_TempFolder.."741993.tmp",false, true,false,nil);
if (current_cj >= (start_sj + 365)) then
-- product has expired
result = Dialog.Message("Notice", "Your installation of this product has expired. This program will now exit.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
File.Run("DATA\\1993ICU2.dll", "", "", SW_SHOWNORMAL, false);
Application.Exit();
end
else
if File.DoesExist(_SystemFolder .. "\\741993.log") then
encdate = Crypto.Base64EncodeToString(_SystemFolder.."\\741993.log", 0);
Registry.CreateKey(HKEY_LOCAL_MACHINE,"Software\\741993\\Data");
Registry.SetValue(HKEY_LOCAL_MACHINE, "Software\\741993\\Data", "sj",encdate, REG_SZ);
TextFile.WriteFromString(_TempFolder.."741993.tmp", System.GetDate(DATE_FMT_JULIAN), false);
encdate = Crypto.Base64EncodeToString(_TempFolder.."741993.tmp", 0);
File.Delete(_TempFolder.."741993.tmp",false, true,false,nil);
Registry.SetValue(HKEY_LOCAL_MACHINE, "Software\\741993\\Data", "cj",encdate, REG_SZ);
else
TextFile.WriteFromString(_SystemFolder.."\\741993.log", System.GetDate(DATE_FMT_JULIAN), false);
encdate = Crypto.Base64EncodeToString(_SystemFolder.."\\741993.log", 0);
Registry.CreateKey(HKEY_LOCAL_MACHINE,"Software\\741993\\Data");
Registry.SetValue(HKEY_LOCAL_MACHINE, "Software\\741993\\Data", "sj",encdate, REG_SZ);
Registry.SetValue(HKEY_LOCAL_MACHINE, "Software\\741993\\Data", "cj",encdate, REG_SZ);
end
end