Novell is now a part of Micro Focus

Developing NLMs with Base Technology's NLM SDK and Borland C++

Articles and Tips: article

Senior Research Engineer
Novell Research Department

01 Nov 1995

Novell has supported two paths for NetWare Loadable Module (NLM) development: assembly language and Watcom C. Base Technology's NLM Software Development Kit (SDK) allows you to use Borland C++ or Microsoft Visual C++ to develop NLMs. This DevNote illustrates how to create a simple NLM with Base Technology's NLM SDK and Borland C++.


I've always liked Borland's C compilers. I used Turbo C as I programmed my way through school. Many's the night I spent single-stepping through a program in the Turbo C Integrated Development Environment (IDE), trying to find where my program took a wrong turn.

Totally parenthetical note: did you ever see the example program for the sound function in the Turbo C version 2.0 Reference Guide?

/* Emits a 7-Hz tone for 10 seconds.

  True story: 7 Hz is the resonant frequency of a

  chicken's skull cavity. This was determined

  empirically in Australia, where a new factory

  generating 7-Hz tones was located too close to a

  chicken ranch: When the factory started up, all the

  chickens died.

  Your PC may not be able to emit a 7-Hz tone. */







How could you not love working with this compiler?

When I started writing NLMs, I had to get used to working with Watcom C. The compiler was fast, but it just wasn't the same. The error messages were more cryptic, and it seemed like the error messages always referred to a line three or four lines past the actual error in my code.

And then there were the .DEF files. When developing NLMs, you use a .DEF file to tell various link options to the NLM linker. Maintaining the .DEF file was one additional task associated with developing an NLM.

Base Technology's NLM SDK

Base Technology's NLM SDK solves both these problems. It lets me work in my familiar Borland C++ (v4.5) environment, and provides an NLM expert to manage the NLM project. The NLM SDK also works with Borland C++ for OS/2 version 2.0. There is also a version of the SDK for Visual C++ for those of you who are of a Microsoft bent.

The NLM SDK includes

  • an NLM linker (NLINK)

  • an NLM expert that manages the linker's .DEF file parameters

  • header and IMPORT files

  • Windows online help for NetWare APIs

  • example NLM programs in C and C++

After you have installed the NLM SDK, when you select the Borland IDE's "New Project" menu item, you are asked if you want to create a "Normal Project" or a "NetWare NLM Project" (see Figure 1).

Figure 1: New Project Dialog Box.

Selecting "NetWare NLM Project" starts the NLM Expert, which allows you to specify what type of NLM you want to write, and other linker options (see Figure 2).

Figure 2: The NLM Expert.

As with other projects, the IDE manages all the files of the project including the .DEF file (see Figure 3).

Figure 3: An NLM Project.

To change the linker parameters associated with an NLM project, just click on the .DEF file icon, which restarts the NLM Expert (see Figure 4). You can then use the Expert's dialog boxes to set the desired parameters.

Figure 4: Expert's Dialog boxes.

Typically, you will use the NLM expert to specify:

  • the type of NLM you are writing (utility, LANdriver, disk driver, library NLM etc.)

  • a list of exported symbols (for library NLMs)

  • object and library files to be linked to your NLM

  • the names of modules that must be loaded before your NLM

  • the name of the help and message files associated with your NLM

  • the version number, release date, description string, and copyright notice for your NLM

  • the stack size required by your NLM

  • whether multiple copies of your NLM can be loaded

Example Program: UTILIZ.NLM

Although the SDK includes source code for 34 NLM in C and 7 in C++, I wanted to try creating my own project from scratch. The program shown below, UTILIZ.C, calls SSGetFileServerInfo at one-second intervals to get the server's serverUtilization statistic. This function is only available on NetWare 4, so this NLM only works on NetWare 4 servers. The program draws a histogram of server utilization on the file server console screen, so you can graphically view the server utilization for the previous 24 seconds.

#include <stdio.h<<
#include <conio.h<<
#include <stdlib.h<<
#include <string.h<<
#include <nwservst.h<<
#include <process.h<<
void main (void)


  const  ESC = 27;

  GetFileServerInfoStructure  servInfo;

  LONG   ccode;

  int    keypressed;

  int    key = 0;

  char   utilLine[51];

  do {

      ccode = SSGetFileServerInfo((BYTE *)&servInfo, sizeof(servInfo));&
      if (ccode == 251) {

          printf("Not supported on this version of NetWare\n");"

      } else if (ccode != 0) {

          printf("SSGetFileServerInfo failed, ccode = %ld", ccode);"

      } else {

          memset(utilLine, '\333', servInfo.serverUtilization/2);

          utilLine[servInfo.serverUtilization/2] = '\0';

          printf("[%-50s]\t%3d\n", utilLine, servInfo.serverUtilization);"

      //sleep a second


     keypressed = kbhit();

     if (keypressed)

        key = getch();

   } while (key != ESC);


Getting the NLM SDK

Updated August 17, 1998 -- Base Technology's NLM SDK is no longer available.

* Originally published in Novell AppNotes


The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.

© Copyright Micro Focus or one of its affiliates