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

1 次查看(过去 30 天)
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

采纳的回答

Mikkel Ibsen
Mikkel Ibsen 2017-9-15
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Platform and License 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by