a0f Subj : Re: How can I make a very large program run? To : borland.public.cpp.borlandcpp From : "Richard Hufford" Date : Fri Feb 13 2004 04:11 pm > You said that error was Invalid Handle. Since there is only the one > handle, it seems obvious that the Open isn't giving the results you > expected. That Invalid Handle error confuses me. OpenPrinter is returning a nonzero value, which should mean that the Open was successful. So, I would think that the handle should not be invalid. >Wondering if > somehow, you are passing the server name instead of the printer name, > or if it is interpreting the name in such a manner? I don't think so, but this is only a guess. I don't know much about print servers. > On other thing, if it was the second call to DocumentProperties() is > your devmode is from a new char[] > I use GlobalAlloc( GMEM_FIXED | GMEM_ZEROINIT, num_bytes ); > So my devmode is blank, whereas your is?? The problem occurs in the first call to DocumentProperties(). It returns a size of -1, so the second call isn't executed. In the case of the smaller program that works, I think it shouldn't matter if the space is initialized to zero or not as long as the DM_IN_BUFFER flag is not specified. Also, you're right when you say I should use delete[]. In the real program, I hold onto the DEVMODE structure until the program stops or the user selects a different printer. > And your Stack! A Stack of 5a8 seems rather paultry to me. Surely, my stack is bigger than that! I haven't had much success reading Win32 maps. That BSS is the stack? My DEF file has a STACKSIZE and a HEAPSIZE of 2000000. Since changing this number to 1800000 in both statements made the problem go away, I did some reading about it. Although the number reserves 2000000 bytes(?), a much smaller amount is actually committed. I can't believe it's only 1448 bytes, though. I don't think my program would go very long like that! About shipping code with Debug on, I think that would make our product too big. But, if that's what works.... I re-linked the program with Image is Based checked on the 32-bit Linker screen, and that reduced the EXE by 100KB, and the program works again. But, if this is a size problem, we're going to run into this again as we add more features. And if it's a programming bug, I'd sure like to find it before we see what else it does! Because Debug is off, could it be that all the code is going into one segment and some segment limit is reached? . 0