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

조회 수: 1 (최근 30일)
Mikkel Ibsen
Mikkel Ibsen 2017년 9월 13일
답변: Mikkel Ibsen 2017년 9월 15일
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