Hello,
I have a validation system by date that works very well, but I don’t know how to do it with the new DateTime, my code is as I put it below, could someone tell me how to redo this so I can go ahead ?
For better understanding, it records a file with the Maximum validation date and checks and writes the current date every time the software is opened in the .dll file so that the validation does not exceed the predicted time and so that turning the computer clock back does not work either.
Thanks in Advance
dim f, f2 as folderitem
dim readbin as binaryStream
dim writebin as binarystream
dim dataexpira as date
dim dataregistro as date
dim teste as boolean
dim datahoje as date
dim datareal as date
dim v1, v2, v3, v4 as string
dim parsedate1, parsedate2, parsedate3 as boolean
dim i as integer
dim b as boolean
f=specialfolder.Desktop.child("Dateok.dll")
if f.exists then
'new dates
datareal=new date
dataexpira=new date
dataregistro=new date
datahoje=new date
'Folderitens
readbin=BinaryStream.open(f, false)
'Read
v1=HexRollDecypher(readbin.readpstring)
v2=HexRollDecypher(readbin.readpstring)
v3=HexRollDecypher(readbin.readpstring)
v4=datareal.SQLDate
readbin.close
dataexpira.SQLDate=V1
dataregistro.SQLDate=V2
datahoje.SQLDate=V3
expirastring="Validation: " + dataexpira.shortdate
if v4>=v1 then 'if the date is bigger tan validated
msgbox "Date error, contact administrator."
writebin=f.createbinaryFile("javascript")
writebin.writepstring HexRollEncypher(dataexpira.SQLDate)
writebin.writepstring HexRollEncypher(dataregistro.SQLDate)
writebin.writepstring HexRollEncypher(datareal.SQLDate)
writebin.close
window1.deleteaction2
quit
elseif v4<v3 then
msgbox "Please Modify the date to corrent date."
window1.deleteaction2
quit
else
writebin=f.createbinaryFile("javascript")
writebin.writepstring HexRollEncypher(dataexpira.SQLDate)
writebin.writepstring HexRollEncypher(dataregistro.SQLDate)
writebin.writepstring HexRollEncypher(datareal.SQLDate)
expirastring="validation: " + dataexpira.shortdate
writebin.close
window2.expirastring.text=expirastring
window2.show
end if
else
Msgbox "App dont validated"
window1.deleteaction2
quit
end if
sorry for my ignorance but if I delete these lines how do I compare date actual, date final and date of the last opening of the App to save the .dll with these new dates ?
Try to move your variable declarations to the location where you actually use the variable. A declaration block hasn’t been needed for years and years.
I used this code for over 7/8 years and it always worked, so I didn’t worry about it, I will do some tests today or tomorrow and I will tell you how the problem was, I hope I can work around the problem.
dim f, f2 as folderitem
dim readbin as binaryStream
dim writebin as binarystream
dim dataexpira as DateTime
dim dataregistro as DateTime
dim teste as boolean
dim datahoje as DateTime
dim datareal as DateTime
dim v1, v2, v3, v4 as string
dim parsedate1, parsedate2, parsedate3 as boolean
dim i as integer
dim b as boolean
Var expirastring As String
f=specialfolder.Desktop.child("Dateok.dll")
if f.exists then
'new dates
datareal= DateTime.Now
REM dataexpira=new date
REM dataregistro=new date
REM datahoje=new date
'Folderitens
readbin=BinaryStream.open(f, false)
'Read
v1=HexRollDecypher(readbin.readpstring)
v2=HexRollDecypher(readbin.readpstring)
v3=HexRollDecypher(readbin.readpstring)
v4=datareal.SQLDate
readbin.close
dataexpira = DateTime.FromString(V1)
dataregistro = DateTime.FromString(V2)
datahoje = DateTime.FromString(V3)
expirastring="Validation: " + dataexpira.ToString(Locale.Current, DateTime.FormatStyles.Short, DateTime.FormatStyles.None)
if v4>=v1 then 'if the date is bigger tan validated
msgbox "Date error, contact administrator."
writebin=f.createbinaryFile("javascript")
writebin.writepstring HexRollEncypher(dataexpira.SQLDate)
writebin.writepstring HexRollEncypher(dataregistro.SQLDate)
writebin.writepstring HexRollEncypher(datareal.SQLDate)
writebin.close
window1.deleteaction2
quit
elseif v4<v3 then
msgbox "Please Modify the date to corrent date."
window1.deleteaction2
quit
else
writebin=f.createbinaryFile("javascript")
writebin.writepstring HexRollEncypher(dataexpira.SQLDate)
writebin.writepstring HexRollEncypher(dataregistro.SQLDate)
writebin.writepstring HexRollEncypher(datareal.SQLDate)
expirastring="validation: " + dataexpira.ToString(Locale.Current, DateTime.FormatStyles.Short, DateTime.FormatStyles.None)
writebin.close
window2.expirastring.text=expirastring
window2.show
end if
else
Msgbox "App dont validated"
window1.deleteaction2
quit
end if
You need to set the encoding in HexRollDecypher with DefineEncoding. After you decypher the bytes (which is what I assume you are doing based on the function name), call DefineEncoding on the return string before you return it.