Chapter 15. Windows, Win32s, and Windows NT

This version of FLEXlm supports the full feature (client and server) of FLEXlm on Windows NT systems and the client library on Windows. On Windows systems, both 16 bit and 32 bit mode applications are supported. 32 bit Win32s applications can be linked with the FLEXlm Windows NT library lmgr32.lib to work in both the Win32s and Windows NT environments.

Supported Compilers

Since the FLEXlm client library on Windows/NT is implemented as a standard DLL, it can interface with almost any compiler. However, to build your vendor daemon on a Windows NT system, FLEXlm supports only the Microsoft C/C++ compiler.

In order for FLEXlm API include files to compile properly on Windows platforms, one of the following three compile time flag must be defined: _MSDOS, _WINDLL, or _WINDOWS. On Windows NT systems, an additional compile time flag, WINNT, must be defined. This flag will be used to include proper macro definitions in lm_clien.h for FLEXlm on Windows and Windows NT systems. If you use the Microsoft C/C++ compiler for Windows, this flag is defined automatically by the compiler.

Stack Space Requirement

The FLEXlm DLL, like all Windows/NT DLLs, operates on the calling application's stack. The FLEXlm DLL requires a maximum of 6K bytes of stack space in addition to your application's stack requirement.

lc_init() and lc_free_job() Must Be Matched

lc_init() creates a license job, and lc_free_job() marks the end of the license job. FLEXlm applications must match lc_free_job() with lc_init() perfectly to avoid unexpected system problems on Windows. The reason for this requirement is the following: FLEXlm issues a Windows Socket WSAStartup() call in lc_init(), and WSACleanup() is issued by lc_free_job(). Failure to match lc_init() with lc_free_job() will cause unmatched WSAStartup() and WSACleanup(), which violates the WinSock specification and often results in an unstable system.

FLEXlm Callback Routines

FLEXlm API supports application callbacks on various events such as lost of license and hostid acquisition. Like all Windows SDK standard callback routines, FLEXlm application callback routines must be declared as an __exported CALLBACK procedure. The callback routine should also be declared in the EXPORT section of your application's .DEF file. In addition, the procedure entry point must be derived from Windows SDK MakeProcInstance() call. The following code segment from the sample program demonstrates how this should be done:

;
;       This is your application .DEF file
;
...............
EXPORTS
Quit @1 ; All FLEXlm callback routines should have
; their individual line in the EXPORTS
; section.
;
;       End of .DEF file
;

//
//FLEXlm callback routine on the event of  lost license.
//CALLBACK is defined in  <windows.h> as _far _pascal.
//Declaring  __export instruct the compiler to generate prolog
//and epilogue to set up and restore DS register from AX. AX
//register will be set to your applications data segment by
// the function whose pointer is returned to you by Windows (NT)
//MakeProcInstance()call (see the next code segment for
//MakeProcInstance() usage).
//
extern "C" void  __export CALLBACK Quit(char *feature)
{
//
// Add application code here to take action when license is
// lost.
//
.....
}


//
//Register callback routines when broken connection to
//license server is detected. FLEXlm application must register
//the pointer returned by MakeProcInstance() as callback
//address.  lpfn will set up application data segment value in
//AX for the prolog of an __export routine to set up its DS
//register.
//

FARPROC lpfn;
lpfn = (FARPROC) MakeProcInstance( (FARPROC) Quit, hInstance );
(void) lc_set_attr (LM_A_USER_EXITCALL, (long) lpfn); 

FLEXlm exit() Callback

Your application must call lc_set_attr(LM_A_USER_EXITCALL, ExitProc) to set a callback routine to take action when FLEXlm loses connection to the license server. The default callback routine, exit(), for FLEXlm on UNIX is not supported on Windows/NT systems.

Default License File

The default location for the license file on Windows and Windows NT is C:/FLEXLM/LICENSE.DAT.

Time Zone Setting

An optional part of FLEXlm's client/server handshake procedure is to check the difference between their system time settings. The allowed difference in minutes is set by the client program using lc_set_attr(LM_A_MAX_TIMEDIFF, x). On Windows and Win32s systems, the FLEXlm client library checks the time zone environment variable, TZ, to adjust local time (set by the DOS TIME command) to Universal Coordinated Time (UCT, the same as GMT) in order to communicate with the FLEXlm server which may be anywhere in the world. On Windows NT systems, the user has to use the control panel to set the time and time zone correctly.

Use the following DOS syntax to set the TZ environment variable:

set TZ=tzn[+|-]hh[:mm[:ss]][dzn]


Note: This is only required if you call lc_set_attr(LM_A_MAX_TIMEDIFF, *).

The tzn must be a three-letter time-zone name, such as PST, followed by an optionally signed number, hh, giving the difference in hours between UCT and local time. To specify the exact local time, the hours can be followed by minutes (:mm), seconds (:ss), and a three-letter daylight savings time zone, dzn, such as PDT. Separate hours, minutes, and seconds with colons (:). If daylight savings time is never in effect, as is the case in certain states and localities, set TZ without a value for dzn. If the TZ value is not currently set, the default is PST8PDT, which corresponds to the Pacific time zone.

For example, to set the TZ environment variable to correspond to the current time zone in Germany, you can use either one of the following forms:

set TZ=GST1GDT
set TZ=GST+1GDT

This uses the letters GST to indicate German Standard Time, though you can use any combination of three letters. This syntax assumes that Germany is one hour ahead of UCT, and that this timezone uses daylight savings time

Node Lock and Hostid for Standalone PCs

As in FLEXlm on UNIX, the FLEXlm for Windows and Windows NT also supports node locking. Several important issues should be considered when designing a node- lock licensing scheme for Windows and Windows NT systems. One or more of the following four options can be adopted to implement the node locking scheme that best fits your products.

  1. Hostid implementation is essential to designing a node lock scheme, and the fact that PCs in general do not have a unique serial number is a problem. FLEXlm for Windows and Windows NT can use the 4-byte volume serial number on the C: drive as the hostid for the PC. Your end-user may issue a DIR command on C: to get the serial number. The serial number is presented by DOS in hex form, and this number can be used in the hostid field of a license file. Please note that when a disk serial number is to be used as a hostid, you must use the format DISK_SERIAL_NUM=xxxxxxxx where x is a hexadecimal number. This is the default solution.

  2. There are two disadvantages to the volume serial number solution. First, disk serial number is only supported by DOS version 4.0 and later. Second, hard disk serial numbers can be changed by software with a single DOS file system IOCTL call. Therefore, FLEXlm offers a hardware solution using an external hardware key available from Globetrotter Software. Where in the license file a hostid is of the form SENTINEL_KEY=xxxxxxxx, FLEXlm will then assume that a hardware key solution for hostid is desired.

  3. On Windows system, FLEXlm can use NDIS or Packet Driver interface specification to retrieve the Ethernet address as a hostid. When generating license files for this type of node lock scheme, simple use the 6 digit Ethernet address without any prefix.

  4. If none of the above solutions is satisfactory, FLEXlm provides a set of callback routines for vendors to implement their private hostid. An application may use lc_set_attr(LM_A_HOSTID_PARSE, x), lc_set_attr(LM_A_VENDOR_CHECKID, x),
    lc_set_attr(LM_A_VENDOR_PRINTID, x), and
    lc_set_attr(LM_A_VENDOR_GETHOSTID, x)

to integrate a private hostid scheme into FLEXlm. The included sample program demonstrates how this can be done in WINTEVW.CPP.

Debugging FLEXlm Windows and Windows NT Application and DLL

The FLEXlm Client Library for Windows and Windows NT includes two sets of DLLs:

Table 15-1. DLLs

DLL Name

Platform

Purpose

LMGR.DLL

Windows

Release version for 16 bit Windows Applications

LMGR.DBG

Windows

Debug version for 16 bit Windows Applications

LMGR32.DLL

Win32s,NT

Release version for 32 bit Win32 Applications

LMGR32.DBG

Win32s,NT

Debug version for 32 bit Win32 Applications

The debug version of DLLs have all the functionality of the non-debug version. In addition, they also include the DLL's symbol table and code to output debug messages. Debug version DLLs use standard Windows (NT) SDK OutputDebugString() to output debug messages to your debugging terminal or the auxiliary display. Where a debugging terminal is not available, you may also use the DebugWin program provided by Windows (NT) SDK to catch those debug messages.

In debug or non-debug mode, your application will link with the import library LMGR.LIB for 16 Windows applications and LMGR32.LIB for WIN32 and Win32s applications. To turn on debug mode, copy the debug version of DLL to the non-debug version before you start your application. To turn off debugging, copy back the original non-debug version DLL. For example, to turn on debugging on Windows system, issue the following commands:

C:\lmgr\bin> copy lmgr.dll lmgr.org
C:\lmgr\bin> copy lmgr.dbg lmgr.dll

To turn off debugging, simple copy the original DLL back:

C:\lmgr\bin> copy lmgr.org lmgr.dll

Unsupported API Routines

The following API service routines are not supported on Windows and Windows NT systems:

  • lc_startup()

  • lc_set_attr(LM_A_PERIODIC_CALL, x)

  • lc_set_attr(LM_A_PERIODIC_COUNT, x)

Sample Client Program

A sample Windows and Windows NT application program and its source code are included. This sample program is written using the Microsoft Foundation Class library. This sample code covers the usage of the basic job initialization and termination, license check-in and check-out, using TCP or UDP as transport protocol, getting the user list, and LSAPI. These API function calls are made in a single file, WINTEVW.CPP. In order for this sample program to work with your vendor daemon, the sample program must be configured to have the same encryption seeds as your vendor daemon. Use the Change Encryption Code button to change the encryption seeds for the sample program to match your vendor daemon.

WINSOCK DLL Compatibility

The FLEXlm Client Library for Windows and Windows NT should operate on any WINSOCK compatible TCP/IP stack. If you are using PathWay Access version 3.0 or PathWay Runtime version 2.0, you must contact Wollongong for a WINSOCK.DLL patch (TC56236.EXE) in order for the DLL to work properly over PathWay TCP/IP stack. Before you acquire the patch from Wollongong, the temporary workaround for PathWay WINSOCK.DLL problem is to type the following command before starting Windows.

C:> set PATHWAY_PATCH=1