How to integrate license file into GUI? (Version 2 - Online Clock)

1 view (last 30 days)
Hi
I was looking for a way to implement a license into a gui, and I found this: https://se.mathworks.com/matlabcentral/answers/286532-how-to-integrate-license-file-into-gui
However, when I look clearly at the code:
function check_license
if now > datenum('2017-01-01') % this code stops working Jan 1, 2017
h = msgbox('Please update your License','License Expired') ;
quit
end
Which I have changed to:
function check_license
if now > datenum('2017-01-01') % this code stops working Jan 1, 2017
waitfor(msgbox('Please update your License','License Expired')) ;
quit
end
But this command "now" gets its time from your computer, so an easy way to cheat the license is just to change the date of your computer before opening the GUI, I need a way for the time to be taken from the internet. Like if there is a command to read: www.timeanddate.com I know servers and computers sync to time.windows.com or time.nist.gov

Accepted Answer

Mikkel Ibsen
Mikkel Ibsen on 15 Sep 2017
If anyone was looking for the same answer I have it here.
function enable = check_license
[~,b]=dos('ping -n 1 www.google.com');
n=strfind(b,'Lost');
n1=b(n+7);
if(n1=='0')
URL = 'http://tycho.usno.navy.mil/cgi-bin/timer.pl';
atomTime = datenum(regexp(urlread(URL), ...
'<BR>(.*)\sUTC','tokens','once'),'mmm. dd, HH:MM:SS');
%sysTime = now;
if atomTime > datenum('2017-01-01') % this code stops working Jan 1, 2017
waitfor(msgbox('Please update your License','License Expired')) ;
enable = 'off';
else
enable = 'on';
end
else
waitfor(msgbox('Please Connect To The Internet','No Internet Connection')) ;
enable = 'off';
end

More Answers (0)

Categories

Find more on Platform and License in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!