SetNLMDontUnloadFlag
Sets a flag in the header of an NLM to prevent the NLM from being unloaded with the UNLOAD command at the system console
#include <nwthread.h>
int SetNLMDontUnloadFlag (
int NLMID);
The following table lists return values and descriptions.
A console operator can unload an NLM from the system console command line by issuing the following command:
UNLOAD NLM_NAME
where NLM_NAME is the name of the NLM being unloaded.
If there is a check function for the NLM (declared with the OPTION CHECK directive), it is called when the "UNLOAD NLM_NAME" command is entered. This function then must decide if it is safe to unload the NLM. If it is safe to unload the NLM, the function returns 0 and the NLM is unloaded. If the function determines that the NLM should not be unloaded, it returns a nonzero value and the following prompt is displayed on the system console:
UNLOAD module anyway? n
In this case, the console operation can choose to unload the NLM anyway, by pressing the "y" key, instead of the "n" key.
If SetNLMDontUnloadFlag is called, the NLM can only be unloaded after ClearNLMDontUnloadFlag is called.
For more information about unloading NLM applications, see CHECK Function (NDK: NLM Development Concepts, Tools, and Functions).
#include <nwconio.h>
#include <errno.h>
#include <stdio.h>
#include <nwthread.h>
main()
{
int NLMID, result;
NLMID=GetNLMID();
result=SetNLMDontUnloadFlag(NLMID);
if(result==ESUCCESS)
{
printf("DONTUNLD.NLM cannot be unloaded now.\n");
printf("Press any key to be able to unload this NLM\n");
getch();
ClearNLMDontUnloadFlag(NLMID);
printf("\nYou can unload DONTUNLD.NLM now.\n");
getch();
}
else
printf("Could not set the don’t unload flag.\n");
}