64-bit Windows 7 fopen prn

你说的曾经没有我的故事 提交于 2020-01-06 14:22:53

问题


I am using my antique Borland Builder 5 with Windows 7 64-bit.

  1. fptr=fopen("\prn","wb") fails. "prn", "prn:" also fail.

  2. fptr=fopen("HP8 lj4","wb") succeeds. But doesn't print anything. The "HP8 lj4" is the name of a printer; in control panel, or via "net view hp8gig".

  3. The console command { print /D:"HP8 lj4" shopping.ln } says "shopping.ln is currently being printed" -- but doesn't print anything either.

  4. Of course I print things on that printer all the time. My beautiful ASCII TSE editor can do it.

Anybody know how to print from a console program in Windows 7?

//Monday, September 12, 2011 5:29 pm. Later I realized my "HP8 lj4" was printing to a file with that name. And I tried to comment here, but apparently failed....


回答1:


Tue 9/13/2011 4:05 pm. The way to print from a console "prn"-oriented program in Windows 7 et al is "net use lpt1: \hp8gig\UrPrinter /PERSISTENT:YES". "UrPrinter" must be "shared". And that's all it takes; my wretched little console program prints fine now. One reason I got confused, aside from natural talent, was that the desired printer was local. It was attached to the computer -- but via USB. After doing this, a command-line like "copy file /b prn" prints.

I knew this before apparently -- I found it in a "printnet.bat" file I wrote, to access a network printer from another computer -- but obviously I forgot.

So the code from the web site I mentioned before was broken -- a few typos -- and even when it worked, didn't. Which is to say, I still don't know how to programmatically do the "net use" thing.




回答2:


Mon 9/12/2011 5:49 pm. OK the general problem is how to redirect the revered & antique "PRN" device on a windows 7 machine to something useful. I don't know how to do that. A fellow at http://comsci.liu.edu/~murali/win32/NetworkPrint.htm has some code which looks like it might make PRN print again, but his plan also suggested trying the network name of my desired printer in my silly program -- and that works. I.e., I stuck in code like

  if (stricmp(name,"prn")==0) {
    name =
#if W7
      "\\\\hp8gig\\HP8 lj4"
#endif
  }

I can make something more sophisticated with an environment variable, or perhaps I'll figure-out the fellow's PRN thing....



来源:https://stackoverflow.com/questions/7366280/64-bit-windows-7-fopen-prn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!