2 App Distribution


Protecting App Code

When Developing Apps with 2017

If there is a desire to protect the Origin C code for an App from viewing or alteration by others, the code requiring protection must be placed into a special password-protected Origin C file called an *.OCZ file. A new OCZ file can be created using Code Builder in the same manner as creating other files. An existing Origin C file can be changed to an OCZ file by selecting Save As Encrypted... and saving it to the App folder. One can then follow the steps in Adding and Deleting Files in an App to change which file will be packaged with the App.

OCZ files can be saved without a password but this defeats their purpose. So one should always set a password when saving the OCZ file. Make sure to record this password somewhere secure because if it is forgotten, there is no way to open the file again. (OriginLab cannot even open an OCZ file without a password.)

Note: If there is any possibility that the App may be distributed to others, make sure not to check Current User Only when saving an OCZ file. This effectively prevents any other user from being able to run the code in the file.

When Developing Apps with 2018 and Later

Unlike developing Apps with Origin 2017, Origin 2018 has made it much easier to protect Origin C code from viewing or alteration by others. Rather than manually adding an *.OCZ file to the App during development, Package Manager has a new setting Encrypt C and CPP Files that, when checked, will automatically convert *.C or *.CPP files included in the App package into OCZ files "on the fly". The Original C or CPP files still exist as part of the App during development, but they are not packaged into the generated OPX file. This means that when users install the App, the original C or CPP files aren't installed- only the OCZ files are installed on their machines.

Note: When toggling Encrypt C and CPP Files either on or off, you must click the Repack button afterwards in order for the OCZ file to be generated or not generated.

Additionally: If you use run.LoadOC() to load and compile your C or CPP files and have enabled this feature, you must modify your run.LoadOC() call(s) to remove the .C or .CPP file extension for the feature to work correctly. For example, change:

run.LoadOC("%@ACD Test App\Source.cpp", 16);

To:

run.LoadOC("%@ACD Test App\Source", 16);

Note: Starting with Origin 2019b, you can replace the App folder name with the %@X string register as follows and it will all magically work:

run.LoadOC("%@A%@X\Source", 16);

In this case, Origin will find your source code file automatically.

Finally, when utilizing this feature, it is strongly encouraged that backups be made of any Origin C sources files (C or CPP files). Though the files are not removed from the App folder during OPX generation, if the App is later uninstalled from the development machine, the source code files will be permanently lost and there is no way to extract them from a previously generated OPX.

Specifying the Version for an App

Origin accepts an App version specifier as #.##. That is, a floating point value limited to two decimal places. For example, 1.23 is a valid version while 1.234 will be treated as 1.23.

Specifying an Origin Pro-Only App

There are a number of methods for creating an App that is meant for OriginPro only. Generally, one must develop an OriginPro-only App using OriginPro.

When Developing Apps with 2017

If one is going to distribute the App on OriginLab's File Exchange, one can specify that the App Requires OriginPro at the time of File Exchange submission. This can prevent the App from being installed by non-Pro users. For more information see Guidelines to Submit a File.

Another method for preventing App installation by non-Pro users is to add the following line of code to the Before Installation script field in Package Manager when generating the App OPX file:

if (@VLP==0) { type -b "This App requires OriginPro. Installation aborted."; break 1;}

That simply checks if OriginPro is running and, if not, aborts the installation.

The most secure method to prevent Pro-only App usage by non-Pro users is to put the important code logic into a password-protected OCZ file specified as "Pro Only". Without the password, the file cannot be modified and only Pro users will be able to run it. One could even combine this with one of the aforementioned installation prevention steps to ensure non-Pro users are fully aware that they must have OriginPro.

Finally, X-Functions can be specified as OriginPro only. This is done in X-Function Builder by enabling Tree View and scrolling down to the Module field and setting the value to Pro. While this is an option, it should be noted that another OriginPro user can simply open the X-function and remove that setting. The most secure way to ensure an X-Function is Pro-only is to put the major code logic for the X-function in a Pro-only OCZ file and include that OCZ file in the X-Function.

When Developing Apps with 2018 and Later

Origin 2018 makes it much easier to specify that an App be OriginPro only. In Package Manager, when the setting OriginPro Required is checked, a flag is set in the generated OPX file that will prevent the OPX file from being installed by non-Pro users.

If the OPX file is uploaded to File Exchange, the app will automatically be listed as OriginPro only.

As well, if the Encrypt C and CPP Files setting is also checked in Package Manager, the OCZ generated "on the fly" will be set to OriginPro only. See Protecting App Code for more information about that setting.

Providing Documentation for an App

Documentation for an App can take a few forms.

If an App is uploaded to File Exchange for distribution, the File Exchange page can be used to provide documentation. When a user clicks on the Help button in an App dialog, the associated File Exchange page will open in a web browser.

Alternatively, documentation in the form of a .*PDF, *CHM, *TXT or similar file format can be included in the folder for the App. This is useful when a App may not be distributed via the File Exchange. If one uses a dialog in an App (whether it be a LabTalk GetNumber dialog, an Origin C dialog or X-Function) the Help button in the dialog can be made to open the relevant documentation file in the folder for the App.

Note: Links to arbitrary web sites are not allowed to be used for the Help button in dialogs.

Distributing an App

Once an App has been finished and a OPX file generated, the App may be distributed to others. If one wants to distribute it only to colleagues, it is simply a matter of providing them the OPX file and having them install it in Origin via drag and drop.

However, if there is a desire to distribute the App to the public at large, it can be listed in the OriginLab File Exchange.

For more information about distributing an App via File Exchange, see Guidelines to Submit a File.

Internationalizing an App

Apps can optionally be internationalized to any of the languages supported by Origin including (English, German, and Japanese). For assistance with internationalizing an App being developed, please contact OriginLab Technical Support.