フィルターのクリア

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 Center および File ExchangePlatform and License についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by