home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware 1 2 the Maxx
/
sw_1.zip
/
sw_1
/
WINDOWS
/
MISC
/
XLMATH10.ZIP
/
XLMINIT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-03-14
|
3KB
|
109 lines
/*******************************************************************
XLMINIT.C
Author: Roy Kari
Dept. of Chemistry
Laurentian University
Sudbury, Ont.
Canada P3E 2C6
(705) 675-1151
Internet: "ROY@NICKEL.LAURENTIAN.CA"
***************************************************************** */
/* --------------------------< Include files >--------------------- */
#include <windows.h>
#include "xlmopti.h"
#include "xlmath.h"
#include "xlmutil.h"
/* -----------------------< global variables >--------------------- */
OMEM_POOL ReturnPool;
OMEM_POOL ScratchPool;
TD TaskDescriptors[MAX_TASK_DESC];
HANDLE hLibInst;
char *szLibName = "XLMATH.DLL"; // used by ErrorHandler
/* -------------------<Windows Entry & Exit Routines>-------------- */
/*********************************************************************
LibMain()
=========
This is the standard windows DLL entry routine. This allocates
a task descriptor in the local heap.
********************************************************************/
BOOL PASCAL FAR _export LibMain(HANDLE hInstance, WORD wDataSegment,
WORD wHeapSize, LPSTR CommandLine)
{
WORD wCount = MAX_TASK_DESC;
NPTD pTaskDesc = &TaskDescriptors[0];
if (wHeapSize > 0)
UnlockData(0);
// init task descriptors
while (wCount--)
{
pTaskDesc->hTask = NULL;
pTaskDesc->lpReturnBuffer = NULL;
}
// init shared memory pools
ReturnPool = MemPoolInit(TRUE);
ScratchPool = MemPoolInit(TRUE);
hLibInst = hInstance;
return (1);
}
/*********************************************************************
WEP()
=====
This function is the standard windows DLL exit routine
********************************************************************/
int PASCAL FAR _export WEP(int bSystemExit)
{
return (0);
}
/* -----------------------<DLL Routines>--------------------------- */
/**************************************************************************
InitXLMath()
=========
This function registers the task with OPTIMEM and initializes a
memory pool. Returns TRUE if the memory pool was properly initialized,
else FALSE. This function must be called in the EXCEL auto_open macro
along with the EXCEL REGISTER functions.
**************************************************************************/
BOOL FAR PASCAL _export InitXLMath(void)
{
HANDLE hCurrentTask = GetCurrentTask();
NPTD pTaskDesc;
// get free task descriptor
pTaskDesc = GetTaskDescriptor(hCurrentTask);
return (pTaskDesc != NULL? TRUE : FALSE);
}
/**************************************************************************
ExitXLMath()
================
This function free's the memory allocated to type K ranges and unregisters
the task with OPTIMEM. This function must be called in the EXCEL auto_close
macro.
**************************************************************************/
void FAR PASCAL _export ExitXLMath(void)
{
HANDLE hCurrentTask = GetCurrentTask();
// free memory used by this task
ExpungeTaskDescriptor(hCurrentTask);
CleanMemory();
return;
}