home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Inside Multimedia 1995 July
/
IMM0795.ISO
/
share
/
os2
/
pmfract
/
src
/
init.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-24
|
2KB
|
51 lines
/***************************************************************************\
* INIT.C -- Library initialization funcitons
* Created by Microsoft Corporation, 1989
\***************************************************************************/
#include "tool.h"
/****************************************************************************\
* This function initializes the file dialog library (by loading strings).
*
* Note: Initialization will fail if CCHSTRINGSMAX is smaller than the
* space taken up by all strings in the .rc file. Fix by increasing
* CCHSTRINGSMAX in wintool.h and maybe also the initial heap size
* in wintool.def.
*
* Returns:
* TRUE if initialization successful
* FALSE otherwise
\***************************************************************************/
BOOL PASCAL InitLibrary()
{
int i;
int cch;
PSTR pch;
PSTR pmem;
int cchRemaining;
/* allocate memory for strings */
if (!(pch = (pmem = WinAllocMem(vhheap, cchRemaining = CCHSTRINGSMAX))))
return FALSE;
/* load strings from resource file */
for (i = 0; i < CSTRINGS; i++) {
cch = 1 + WinLoadString(HABX, vhModule, i, cchRemaining, (PSZ)pch);
if (cch < 2)
/* loadstring failed */
return FALSE;
vrgsz[i] = pch;
pch += cch;
if ((cchRemaining -= cch) <= 0)
/* ran out of space */
return FALSE;
}
/* reallocate string space to size actually needed */
WinReallocMem(vhheap, pmem, CCHSTRINGSMAX, CCHSTRINGSMAX - cchRemaining);
return TRUE;
}