Home » RLM with Visual Basic 6

Using RLM with Visual Basic 6-Abstract Technology Background

RLM with Visual Basic 6

Visual Basic 6 programs may call RLM functions to implement software licensing functionality. There are a few extra steps that must be taken beyond what’s needed in C/C++ programs to make it work however. This is a description of those steps.

Using RLM with Visual Basic 6

Step 1:

Download and Build the RLM SDK

graphic of software box showing a key being installed and a progress bar below itThis process is described in the RLM Getting Started Guide.

One of the products of the SDK build is rlm.dll, a dll containing the RLM functions in executable form. It is these functions that will be called from VB6.

Step 2:

Build an Interface DLL

Visual Basic-interface DLLBecause Visual Basic and C use different conventions for calling functions, and because C can be made to use Basic’s conventions but the reverse is not true, you must build a simple interface layer in C which accepts function calls in Basic using Basic’s conventions, and calls C using C’s conventions. This layer is very simple. For each RLM function call to be made from Basic, write a C wrapper function. Each function should:

  • Have a name <rlm-function>_stdcall and invoke the corresponding <rlm-function>
  • Declare arguments identical to the corresponding RLM function
  • Include “ stdcall” between the function’s return type and the function name (stdcall is what tells the compiler to expect to be called with Basic calling conventions)

Here is an example rlmstdcall.c, using 6 fundamental RLM functions:

Visual Basic-Screenshot

An exports definition file must also be created, naming each wrapper function. Here is an example rlmstdcall.def, exporting the 6 wrapper functions from the example above:

Visual Basic-Screenshot

 

With the C source file rlmstdcall.c and the exports file rlmstdcall.def in place, the dll rlmstdcall.dll is built as follows (this assumes that the c file and the def file are in the x86_w3 directory on the RLM SDK):

$ cl /c /MD /I..\src /Forlmstdcall.obj rlmstdcall.c
$  link /nologo  /dll  /out:rlmstdcall.dll   /def:rlmstdcall.def
rlmstdcall.obj rlm.lib

Step 3:

Create Basic Function Declarations for the RLM Functions to be Called

For each RLM function to be called from Basic, write a Basic function declaration for it. The declaration specifies the data type of each argument and how to pass it, and the function’s return type. Arguments should be passed by value, using the “ByVal” specifier. C and Basic types used by RLM are as follows:

Visual Basic-Table

 

Here is an example of the Basic function declarations of the 6 RLM functions used in previous examples:

Visual Basic-Screenshot

Step 4:

Add RLM Function Calls to your Basic Program

Here is a small example Basic program using some of the functions from the previous examples:

Visual Basic-Screenshot

Leave a Reply

Your email address will not be published. Required fields are marked *