PDA

View Full Version : Do not pass GO do not collect $200


Bruce
06-06-2004, 02: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

SUF6NEWBIE
06-07-2004, 11:46 AM
Bruce...quick suggestion

break some of your code up into 'smaller' controlled pieces
(drop some of the "else" controls) this will help you
diagnose..you could also try breaking it up into smaller
'globals' that you can call 'conditionally from the First Global
--are they mucking around with systemclock--registry key exist etc.
call in your 'Startup' actions
make separate global funcs. for 'red' and for 'blue' etc

maybe call your target func from the 'page'-s your using

If ...... then
--call the red stuff global func.
redstuff();
--the red func can have the App.exit
end

if ...then
--call the blue stuff func.
bluestuff();
end

if (not) ..... then
..whatever else here
end

using the separate funcs can make it easier to 'tweak' each major
'control you're after

very broard I know, hope helps a litttle

BTW another possibility could be to change from num days
to total hours of usage regardless of current date...

Bruce
06-07-2004, 12:07 PM
Thanks SUF6NEWBIE for your input!

SUF6NEWBIE
06-07-2004, 12:34 PM
..one guy I know wacks the 'install date' & 'file date' info as
part of the 'registry entry' trial serial number the user enters
(does some math calc and 'cryptos' for the actual serial in the
registry..)

Bruce
06-07-2004, 02:33 PM
Yep that's what's going on here using the MAC address.