How to integrate license file into GUI?

1 view (last 30 days)
adi kul
adi kul on 31 May 2016
Commented: Image Analyst on 10 Jun 2020
Hello, I am developing the GUI for a script. For this I want to have a license time check. For this simple purpose I have created license.m with following function:
function output = license(varargin)
if now > datenum('2017-01-01') % this code stops working Jan 1, 2017
h = msgbox('Please update your License','License Expired') ;
return
end
end
Now I need help in calling this file in my Matlab GUI script. I want to have this check at beginning of the execution.

Answers (1)

Walter Roberson
Walter Roberson on 31 May 2016
If you are using GUIDE then look in the generated code, and put your call to your license check just before the line
% Begin initialization code - DO NOT EDIT
  5 Comments
Image Analyst
Image Analyst on 10 Jun 2020
chek_license contains these lines of code:
if now > datenum('2017-01-01') % this code stops working Jan 1, 2017
h = msgbox('Please update your License','License Expired') ;
quit
end
A better way would be this:
% Check that user has the specified Toolbox installed and licensed.
hasLicenseForToolbox = license('test', 'matlab'); % Check for base MATLAB.
% hasLicenseForToolbox = license('test', 'Image_Acquisition_Toolbox'); % Check for Image Acquisition Toolbox.
% hasLicenseForToolbox = license('test', 'Statistics_Toolbox'); % Check for Statistics and Machine Learning Toolbox.
% hasLicenseForToolbox = license('test', 'Signal_Toolbox'); % Check for Signal Processing Toolbox.
% hasLicenseForToolbox = license('test', 'Video_and_Image_Blockset'); % Check for Computer Vision System Toolbox.
% hasLicenseForToolbox = license('test', 'Neural_Network_Toolbox'); % Check for Deep Learning Toolbox.

Sign in to comment.

Categories

Find more on Manage Products in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!