Preventing a library from being run

by Jon Ripley, July 2006, January 2007

To prevent a library from being run add the following code to the start of the library after any initial comment block to generate a syntax error when a user tries to run your library:

        ;


To generate a more descriptive error instead add the following code to the start of your library:

        SYS "MessageBox", @hwnd%, "This is a library and cannot be run.", 0, 48
        QUIT


The message appears in a message box and the program will quit when it is dismissed. This necessarily adds 78 bytes to the library, even when added to a compiled program, but ensures that the library will not be executed and alerts users that the library is not an executable program.