Subj : Re: How can I make a very large program run? To : borland.public.cpp.borlandcpp From : Bob Gonder Date : Wed Feb 11 2004 11:01 am Richard Hufford wrote: >>Did you check the result of GetProfileString()? Does it return the >>correct printer name when things fail? > >Yes, I checked the result of GetProfileString() and it does return the >correct printer name. Also, the call to OpenPrinter() returns TRUE. I >don't get an error until the first call to DocumentProperties(). 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. Looking at OpenPrinter docs, it mentions that you can "open" the print server rather than a printer on the server. 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? 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?? Then, later you delete devmode, but shouldn't it be delete[] ? >April 2000 version of the MSDN Library and it has a Knowledge Base article >Q135387, which says that GetProfileString() is the best way to find the >default printer, even if the profile is not stored on the WIN.INI file. Ok. Guess they can change their minds... >My method of getting the default printer seems to work, as long as the >program is reasonably small. Is there any way to find out whether or not I >have reached a limit of some sort and what that limit might be? Your app isn't all that big. My own map is this Start Length Name Class 0001:00401000 000073B83H _TEXT CODE 0002:00475000 00005C68CH _DATA DATA 0003:004D168C 0000CAB10H _BSS BSS 0004:00000000 00000009CH _TLS TLS Plus several megs of uninitialized data structures. You have over twice the code, but your data is smaller. And your Stack! A Stack of 5a8 seems rather paultry to me. I believe the default Windows stack is 1 meg. My app would blow your stack before it got to the first screen :-) And device[201] is taking a fairly large chunk of that 1448 byte stack space. About your next message..Debug. Some people (myself included) ship the code they test. That means debug info is always on. Some shops have concerns that turning debug on/off changes the executing code, and may introduce (masked) bugs. I've seen bugs go away when viewed through the debugger because it micro manages memory in ways that your app on it's own wouldn't encounter. Debug can also sometimes "fix" compiler "problems" that are, as it turns out, a (subtle?) misuse of the language. .