|
|
1.1 ! root 1: /***************************************************************************\ ! 2: * INIT.C -- Library initialization funcitons ! 3: * Created by Microsoft Corporation, 1989 ! 4: \***************************************************************************/ ! 5: ! 6: #include "tool.h" ! 7: /****************************************************************************\ ! 8: * This function initializes the file dialog library (by loading strings). ! 9: * ! 10: * Note: Initialization will fail if CCHSTRINGSMAX is smaller than the ! 11: * space taken up by all strings in the .rc file. Fix by increasing ! 12: * CCHSTRINGSMAX in wintool.h and maybe also the initial heap size ! 13: * in wintool.def. ! 14: * ! 15: * Returns: ! 16: * TRUE if initialization successful ! 17: * FALSE otherwise ! 18: \***************************************************************************/ ! 19: ! 20: BOOL PASCAL InitLibrary() ! 21: { ! 22: int i; ! 23: int cch; ! 24: PSTR pch; ! 25: PSTR pmem; ! 26: int cchRemaining; ! 27: ! 28: /* allocate memory for strings */ ! 29: if (!(pch = (pmem = WinAllocMem(vhheap, cchRemaining = CCHSTRINGSMAX)))) ! 30: return FALSE; ! 31: ! 32: /* load strings from resource file */ ! 33: for (i = 0; i < CSTRINGS; i++) { ! 34: cch = 1 + WinLoadString(HABX, vhModule, i, cchRemaining, (PSZ)pch); ! 35: if (cch < 2) ! 36: /* loadstring failed */ ! 37: return FALSE; ! 38: vrgsz[i] = pch; ! 39: pch += cch; ! 40: ! 41: if ((cchRemaining -= cch) <= 0) ! 42: /* ran out of space */ ! 43: return FALSE; ! 44: } ! 45: ! 46: /* reallocate string space to size actually needed */ ! 47: WinReallocMem(vhheap, pmem, CCHSTRINGSMAX, CCHSTRINGSMAX - cchRemaining); ! 48: ! 49: return TRUE; ! 50: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.