Why does it require the Print Spooler service for simple copy/paste operation? - Page 1
Forum section: electronics / general

author: hkBattousai
author_rank: Regular Contributor
timestamp: February 05, 2015, 05:50:43 am
content: I have disabled several unused Windows 7 services in order to save CPU and and RAM. The Print Spooler service was one of these.After installing a fresh Altium Designer 15, I created a schematic sheet, placed a simple component on it, I tried to copy it by Ctrl+C, and I received the following error.Code:InvalidParameter at 19785E08.AdvSch.dll, Base Address: 192F0000.Exception Occurred InCopyAfter a little Google search, I found out that the problem is the Print Spooler service not being running. I enabled and started it, and then the issue was solved.I'm just curious. Why does Altium Designer require such an irrelevant service to be running for doing copy/paste job? I could understand it if it had given that error when I attempted to print a document. Is there an explanation for this behavior? Is there a setting somewhere which will fix this error?

author: Richard Crowley
author_rank: Super Contributor
timestamp: February 05, 2015, 06:16:27 am
content: It seems within the realm of possibility that they used the spooler as a handy "scratchpad". So when you "copy" something it writes the data into some temporary spot. So that when you "paste" it, the data is retrieved and copied into the desired place. The spooler may have just been a convenient "scratchpad" as a temporary storage are for the cut/paste operation. By using the spooler device in the operating system, they don't have to create a scratchpad on their own, and the OS takes responsibility for a lot of housekeeping, etc.

author: elgonzo
author_rank: Unknown
timestamp: February 05, 2015, 06:57:24 am
content: Things that happen when software developers have to drink cold coffee...

author: Rigby
author_rank: Super Contributor
timestamp: February 05, 2015, 01:56:02 pm
content: Quote from: hkBattousai on February 05, 2015, 05:50:43 amYou're not going to save much CPU or RAM doing that unless you do it on 1,000 machines and measure your savings across all of them.Quote from: hkBattousai on February 05, 2015, 05:50:43 amIt doesn't seem like an irrelevant service to me. In fact, it seems very relevant. You believing that the service is irrelevant doesn't actually make it irrelevant.

author: miguelvp
author_rank: Super Contributor
timestamp: February 06, 2015, 06:48:33 am
content: The printer might take a while to warm up, or it's out of paper and can't hold your document in memory while waiting for more paper, or any other reason.The question is, why did you disable services that you didn't know what they did?That's asking for trouble.if in doubt google will tell you if it's an OS service or 3rd party and what it does (good or bad)Maybe you prefer that AD keeps trying to connect directly to the printer instead of letting you work on other things while the spooler is taking care of your print job?

author: zapta
author_rank: Super Contributor
timestamp: February 06, 2015, 07:34:44 am
content: Quote from: Rigby on February 05, 2015, 01:56:02 pmCan you explain why the print spooler is relevant to a copy-to-the-clipboard operation.

author: elgonzo
author_rank: Unknown
timestamp: February 06, 2015, 08:03:48 am
content: Quote from: miguelvp on February 06, 2015, 06:48:33 amI am pretty sure that hkBattousai knows what the Printer Spooler service is and what it does.The question should rather be: "Why didn't you know about all the printing-unrelated nonsense AD does with the Printer Spooler service?"

author: miguelvp
author_rank: Super Contributor
timestamp: February 06, 2015, 08:30:11 am
content: True, also alt ptrscr and ctrl ptrscr is probably part of it as well, so print buffers and the clipboard are probably related.Why? no idea, old CPM-80 was able to pipe files to/from devices so could ms-dos copy or unix cp.So I guess Windows decided to put the clipboard as part of the print system when things became complicated?

author: Richard Crowley
author_rank: Super Contributor
timestamp: February 06, 2015, 08:55:17 am
content: Or it could also be possible that the developer needed to store more complex data than could be accomodated in the "clipboard", and the print buffer turned out to be a convenient solution.However, I admit that if I had developed software like that, I would do a check upon startup to confirm that all the different OS services I need are available, and throw an error message of complaint upon launch. Although it seems relatively reasonable to expect that things like print spooling were not intentionally turned off. That seems quite outside "normal" operation.

author: Mechatrommer
author_rank: Super Contributor
timestamp: February 06, 2015, 11:59:36 am
content: Quote from: Rigby on February 05, 2015, 01:56:02 pmthe name is "print spooler" not "clipboard spooler". windows has special (API) place for "special clipboard". you set a "special id" to a particular "special data to be placed in memory", and then you have a "special clipboard" independent of other clipboard type. i agree the developer lack of caffeine during decision making, this is the hidden ugly truth in pro sw development world where a developer has to sort out to another hack. now the fart is leaked, from he that should not be named. :edit: or maybe it has reason to doing so, such as capability of storing larger than RAM data. but for small clipboard, its indication of laziness for easy-generalized-simpler code, cant really blame them, they need food fast.

author: Rigby
author_rank: Super Contributor
timestamp: February 06, 2015, 02:35:56 pm
content: Maybe there's some technical reason you can't see that mandated use of it. Maybe not.Bitching about it won't fix it. Enable the fucking print service and move on with your life.

author: Mechatrommer
author_rank: Super Contributor
timestamp: February 06, 2015, 03:17:58 pm
content: then even if they ask us to eat sheet to make it works then we have to eat sheet. anyway, wrong place and forum for the thread, it should be in the altium support mailbox, only they can answer.

author: Rigby
author_rank: Super Contributor
timestamp: February 06, 2015, 05:27:33 pm
content: Quote from: Mechatrommer on February 06, 2015, 03:17:58 pmI would be surprised if they ever answered that question, much less fixed it. They use freaking Delphi to develop Altium Designer. That alone is a goofball decision, to me, forget the damn copy/paste print spooler nonsense.

author: DIPLover
author_rank: Regular Contributor
timestamp: February 06, 2015, 06:01:02 pm
content: Quote from: Rigby on February 06, 2015, 05:27:33 pmWhy is Delphi goofball in a 15+ years old product?Would you say C# .net with Windows Forms would be goofball? That's mostly "2nd generation" Delphi, from the same Team poached from Borland. (And quite better too, but the folks at Altium have a technical debt).Also to OP :If you can afford Altium 15, WTF are you poking around disabling windows services to save a meg of ram in 2015?

author: ehughes
author_rank: Frequent Contributor
timestamp: February 06, 2015, 07:37:26 pm
content: Delphi is a real, compiled language that equals the performance of any other compiled language. Given it's roots in Pascal, is not necessarily a bad choice.Given that the code development started a long time ago when Borland ruled the roost for windows development, it makes no sense to port it to C++. You could do all that work and end up with the same result. In the end, the end user really does care as long as the tool works.Some people claim it is harder to find programmers for it but if a good programmer can't spend a little time learning the syntax in a week or 2, they are simply not competent.You simply don't change your language with a 20+ year history because of the latest fad.

author: zapta
author_rank: Super Contributor
timestamp: February 06, 2015, 07:52:35 pm
content: Quote from: ehughes on February 06, 2015, 07:37:26 pmJob market must be very limited if they can attract good developers to program in Delphi. It screams LEGACY!.

author: Richard Crowley
author_rank: Super Contributor
timestamp: February 06, 2015, 07:58:29 pm
content: Quote from: zapta on February 06, 2015, 07:52:35 pmHA!QuoteAnd most people here probably never even heard of COBOL and probably wouldn't recognize it if they tripped over it.

author: aroby
author_rank: Regular Contributor
timestamp: February 06, 2015, 08:45:49 pm
content: There are many thousands of systems still running, being maintained and even developed in COBOL.As an aside, there is at least one large, well known tax agency who's core tax systems are still in mainframe assembler and who continues to train programmers in that language. The system described in the March 1966 issue of Popular Mechanics is remarkably similar to the one that runs today.

author: gxti
author_rank: Frequent Contributor
timestamp: February 07, 2015, 01:48:30 am
content: It's worth noting that OP never "bitched" about anything, and was just curious, and had already turned the service back on. It's apparently everyone else who thinks that relying on an on-by-default-unless-someone-monkeyed-with-it service is a sign of incompetent programming. Personally, I find the occasional "catastrophic failure" dialog boxes much more troubling.As for legacy programming, that's where the money is -- snobby twentysomethings (OK, maybe I am one) might not touch it with a ten-foot pole but their dads are more than happy to take in six figures working on banks' "legacies".

author: aroby
author_rank: Regular Contributor
timestamp: February 07, 2015, 03:10:21 am
content: Quote from: gxti on February 07, 2015, 01:48:30 amIndians and Filipinos as well

author: Mechatrommer
author_rank: Super Contributor
timestamp: February 07, 2015, 03:31:24 am
content: delphi is fine as long as making "program" is concerned thats what its for. but compared to C and Basic, delphi s abysimal in "practical purpose", it tried to be both of the 2. now dont mourn about Basic i know, you just dont get the point of it, yes its not for pro... basic is for human friendly language, c is for powefulness, delphi tried to be in the middle. but anyway delphi, basic, asm or c who cares? as long as it makes millions of money for me, its just a tool to accomplish ones desire. and that ones desire accomplishes what others desire... ie making money out of pcb, thats all matters.

author: SeanB
author_rank: Super Contributor
timestamp: February 07, 2015, 04:57:01 am
content: Quote from: aroby on February 07, 2015, 03:10:21 amRBS......................They are still picking up the pieces.

author: elgonzo
author_rank: Unknown
timestamp: February 07, 2015, 09:33:03 pm
content: Quote from: miguelvp on February 06, 2015, 08:30:11 amPrtscr/Alt+Prtscr/Ctrl+Prtscr has nothing to do with the printer spooler either.Their functions are handled by Windows' desktop manager directly, copying all or a part of the desktop surface bitmap into the clipboard.(The historic name of that Prtscr key is misleading with regard to its purpose in Windows. In DOS, the content of the text-screen was sent to the printer port when this key has been pressed. Linux/Unix/OSX might handle the Prtscr key differently from Windows, i don't know...)

author: miguelvp
author_rank: Super Contributor
timestamp: February 07, 2015, 09:58:25 pm
content: On the other hand, you can copy a file to the printer from dos,unix, etc.. even CPM-80 with the PIP command but as far as I know that just talked to the port directly or via int 21h on x86 with the ibm bios or clones of it but things have changed a bit since then.

author: free_electron
author_rank: Super Contributor
timestamp: February 07, 2015, 10:39:06 pm
content: I may be able to shed a light on that. i have done a bit of coding in Delphi years ago and i remember something about the drawing canvas.the print spooler has some interesting features when it comes to handling vector data.Delphi (other languages can use this too but in delphi it is more integrated) uses a drawing surface called the canvas. The canvas can be tied to the windows GUI API or the the printer services.Drawing a string on a window is the same as drawing a string on the printer. So the canvas allows you to make identical representations. You can send exactly the same drawing primitives to the screen or to the printer.On the printer canvas the sequence is preserved not as graphics but as the list of actual commands called to create the graphics.pulling the data back from the printer canvas you can 'replay' the sequence to recreate the graphics.i can have a program send its output to the spooler , intercept it using a hook and send the same sequence to the display . ( that is actually how windows does a print preview. they simply send the spooler data to the window handler. )for a cad program this is great. the clipboard deals with a rendered result. the canvas deals with the calls to create the result.the clipboard can technically accept the list of calls as well but they show up as text or binary data. the problem is that the clipboard can hold too many datatypes that are not compatible .so by using the spooler services you have exactly the same primitive set as the screen. problem solved.the windows spooler doesn't do anything with the data. that is the job of the printer driver. the spooler is just a storage space to offload data from the programs so the printer drivers can get to it.other programs can use this trick as well you can select a schematic in altium hit copy and simpy paste it in word.the copy command does two things : it creates a spooled version to be used inside altium and an EMF to be pasted on the clipboard so other programs can use it.it is a clever way to use resources.anyway. there is no need to muck around with the operating system to try to optimise cpu and ram.Altium 15 runs fine on a four year old machine here at home ( I5-760 quadcore , 4 gig of ram , win7 -32 bit professional , GTX260 graphics card. )By today's standard this is a mediocre machine. It runs just perfectly fine without delays or hiccups.No need to muck about with the OS.

author: Rigby
author_rank: Super Contributor
timestamp: February 07, 2015, 10:54:18 pm
content: Thank you. I'm glad there is a reasonable explanation.

author: Mechatrommer
author_rank: Super Contributor
timestamp: February 08, 2015, 02:52:05 am
content: Quote from: free_electron on February 07, 2015, 10:39:06 pmi dont think word retrieves pasted data from print spooler...

author: zapta
author_rank: Super Contributor
timestamp: February 08, 2015, 03:06:45 am
content: Quote from: Mechatrommer on February 08, 2015, 02:52:05 amThat sounds like a windows 3.1 workaround.

author: elgonzo
author_rank: Unknown
timestamp: February 08, 2015, 03:40:35 am
content: The whole thing sounds like old code base and/or spaghetti code.Remember, the canvas has to draw the schematic symbols when you load a project or add a new component.Hence, there are already drawing routines that draw components and whatnot based on an in-memory data model. For copy&paste, the straight-forward way would be copying of the selected objects/parameter sets and use the already existing drawing routines for rendering. The copied objects/parameter sets would eventually need to be added to the in-memory data model anyway (paste operation). There is no functionality that would benefit from using the spooler.If it is true what free_electron said about Altium, then this is an unnecessarily complex and contrived way of doing things, because it still needs the 'normal' drawing routines, it still needs to copy&paste the selected objects/parameter sets in the data model, and yet it chooses not to use the existing drawing routines when rendering the respective components on the canvas while doing a copy&paste operation but rather introduces yet another method of how to draw components on the canvas. This looks like code smell or a hack...However, i agree with that disabling the service in an attempt to improve performance is unnecessary micro optimization theatre...

author: Rigby
author_rank: Super Contributor
timestamp: February 08, 2015, 04:49:16 am
content: It sounds like a good way to copy and paste resolution independent graphic information to me.

author: elgonzo
author_rank: Unknown
timestamp: February 09, 2015, 12:55:17 am
content: Quote from: Rigby on February 08, 2015, 04:49:16 amTo make it abundantly clear: In a sane code base, there is no need to copy&paste graphics information. But copy&paste requires updating of the internal memory model. Rendering of the updated internal memory model is the job of the (already existing) drawing routines. And drawing routines are resolution independent anyways (well, they should be; anything else would be really stupid.) Why would anyone opt to avoid the drawing routines? To improve performance by a few microseconds perhaps? If there would be a real performance gain for copy&paste actions by copying+pasting graphical information instead of using the drawing routines of the application, then the drawing routines are utter crap...Anyway, it is just a speculation that Altium uses the printer spooler for copy&paste of graphics information. I don't really know Altium, it could very well be that there is another meaningful, somewhat exotic reason of why Altium uses the spooler for copy&paste...

author: Mechatrommer
author_rank: Super Contributor
timestamp: February 09, 2015, 02:03:28 am
content: need to copy paste graphic (bitmap) from to clipboard? use CF_BITMAP or CF_DIB. need resolution independent just as in vector graphics? the host application must provide the rendering mechanism... use OLE service, provide the OLE module please...

author: baljemmett
author_rank: Unknown
timestamp: February 09, 2015, 07:12:11 pm
content: Quote from: Mechatrommer on February 09, 2015, 02:03:28 am… or just provide a metafile with CF_ENHMETAFILE, which is basically what free_electron is describing. Mind you, I've not done enough poking around in that area to know how it relates to the print spooler, except that the print spooler itself has the ability to create and replay metafiles internally if configured to use EMF-format spool files. Personally I'd have expected an app to be able to use CreateEnhMetaFile without involving the spooler service, though, so who knows what's really going on?

author: Rigby
author_rank: Super Contributor
timestamp: February 10, 2015, 12:14:01 am
content: Quote from: elgonzo on February 09, 2015, 12:55:17 amHow many fully sane codebases have you come across, realistically? I've been programming for nearly 2 decades, and I can count on a hand with no fingers exactly how many I've come across.

author: elgonzo
author_rank: Unknown
timestamp: February 10, 2015, 02:30:26 pm
content: Quote from: Rigby on February 10, 2015, 12:14:01 amI am not sure what you are getting at.Are you trying to say that seeing enough real-world code containing hacks and such will turn a hack into what you called a "good idea"? Or is your comment rather unrelated to the speculation about why the spooler is being used by AD?

author: Rigby
author_rank: Super Contributor
timestamp: February 10, 2015, 04:19:47 pm
content: I'm saying that there are always things in codebases that make zero sense on the surface, giving the appearance of a non-sane codebase, and when those decisions were made, the choice may or may not have been the best option.I'm saying that sometimes there are good reasons, sometimes not, and I'm saying that I've never seen an in-production codebase that didn't have lots of odd decisions hard-coded in.I agree that a SANE codebase would do things properly, and I've never come across a sane codebase, by that measure.

author: elgonzo
author_rank: Unknown
timestamp: February 10, 2015, 04:48:55 pm
content: Quote from: Rigby on February 10, 2015, 04:19:47 pmOkay, that makes sense, and i agree. Had difficulty understanding what you were meaning with "good idea".Having been an employed software developer myself (industrial design/product design applications), i have seen my share of hacks, and well, also have made a few hacks myself. Especially in larger code bases, touching existing production code bears a significant risk of breaking existing features and/or introducing new bugs. (That's what code branches are for.) Aside from risks regarding code changes, work on improving (existing) code bases allocates developer resources - something companies with limited resources/finances naturally do not want if it does not translate to a tangible benefit for the customer (i.e., sales points such as improved performance or new features). This and other factors (such as deadlines , company vision, brand management, etc...) can make the application of hacks a viable economic decision and for the company worth more than the cost it imposes on code maintenance."Good ideas" with regard to programming i rather associate with something like "best practices". On the other hand, hacks are a "necessary evil" because of the way the code base of larger software products evolve over time under economic pressures.

author: Rigby
author_rank: Super Contributor
timestamp: February 10, 2015, 04:57:49 pm
content: Yep, and sometimes it's just easier as a developer to implement a hack knowing it's a hack because you're tired of trying to fix something the "correct" way, or because there is a more interesting problem next in the queue, or there is a significant time pressure to just get it done.I've not worked with any professional developer who hasn't done so, and I've not worked on a single codebase that was fully implemented "correctly."

author: zapta
author_rank: Super Contributor
timestamp: February 10, 2015, 05:11:50 pm
content: Quote from: Rigby on February 10, 2015, 04:57:49 pmI agree, it's a hack, regardless of the "justification". ;-)Probably inherited from the Delphi environment or implemented years ago on an older version of Windows.

author: free_electron
author_rank: Super Contributor
timestamp: February 10, 2015, 06:16:31 pm
content: To clarify : this not required inside altium. It is done to share data with other programs.

author: elgonzo
author_rank: Unknown
timestamp: February 10, 2015, 06:18:42 pm
content: Quote from: free_electron on February 10, 2015, 06:16:31 pmThat's what the clipboard and the EMF format is for. You even said so yourself...<Edit: Ha, i said "EMF format". Redundancy ahoy!>