Consultor Eletrônico



Kbase 15083: LoadLibrary is necessary for some DLL
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
LoadLibrary is necessary for some DLL

INTRODUCTION:
=============
If customer has problem running DLL with Progress, one possible
reason is that the DLL is unloaded while it is still needed.

WHY YOU NEED TO KNOW THIS:
===========================

For example, if you run a DLL to open a com port and then check the
UART, there are two entryoints in this process. Progress, by default,
loads and unloads the DLL each time we call one of its entrypoints.
To have the DLL performing both tasks, we need to keep it loaded for
the entire process.

PROCEDURAL APPROACH:
====================
By doing a LoadLibrary on it before any of the entrypoints are called
and then doing a FreeLibrary after it is used, we keep the use count
above 0 for the whole time and windows keeps it loaded the whole time.

SAMPLE CODE:
============

DEFINE VARIABLE DLL_Handle AS INTEGER NO-UNDO.

PROCEDURE LoadLibrary EXTERNAL "KERNEL.EXE":
DEFINE INPUT PARAMETER LL_FileName AS CHARACTER.
DEFINE RETURN PARAMETER LL_Handle AS SHORT.
END PROCEDURE.

PROCEDURE FreeLibrary EXTERNAL "KERNEL.EXE":
DEFINE INPUT PARAMETER LL_FileName AS SHORT.
END PROCEDURE.

RUN LoadLibrary (INPUT 'C:\TEMP\X\PPRTR.DLL', OUTPUT DLL_Handle).

MESSAGE DLL_Handle VIEW-AS ALERT-BOX.

RUN FreeLibrary (INPUT DLL_Handle).


NOTE:
=====

For WindowsNT you can use the LoadLibraryA procedure which is located
in "KERNEL32.DLL".


ONLINE PROCEDURES OR UTILITIES:
===============================


REFERENCES TO WRITTEN DOCUMENTATION:
====================================

Progress Software Technical Support Note # 15083