www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - Output to USB printer

↑ ↓ ← "Heinz-Peter Nuettgens" <hnuettgens t-online.de> writes:
Thanks for your suggestions, but it doesn't work like it should.

I cannot open the USB device by   fopen( "PRN:"...
and I don't find a possibility to redirect for example LPT1: to the USB
device.

Is there any possibilty just to open a stream to the windows standard
printer
without having to care where it is located at all??

Heinz-Peter Nuettgens
Mar 14 2001
↑ ↓ → Arjan Knepper <jak01 pop3.NL.net> writes:
Heinz-Peter Nuettgens wrote:

 Thanks for your suggestions, but it doesn't work like it should.

 I cannot open the USB device by   fopen( "PRN:"...
 and I don't find a possibility to redirect for example LPT1: to the USB
 device.

 Is there any possibilty just to open a stream to the windows standard
 printer
 without having to care where it is located at all??

 Heinz-Peter Nuettgens

Print to LPT1 as you used to do and redirect the lpt1 port to the windows printer you want to use. See windows help "net use" command. When you don't want to do it this way you probably need to open a device directly using the DeviceIOControl and the CreateFile API functions. DeviceIoControl The DeviceIoControl function sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation. BOOL DeviceIoControl( HANDLE hDevice, // handle to device DWORD dwIoControlCode, // operation control code LPVOID lpInBuffer, // input data buffer DWORD nInBufferSize, // size of input data buffer LPVOID lpOutBuffer, // output data buffer DWORD nOutBufferSize, // size of output data buffer LPDWORD lpBytesReturned, // byte count LPOVERLAPPED lpOverlapped // overlapped information ); CreateFile The CreateFile function creates or opens the following objects and returns a handle that can be used to access the object: Consoles Communications resources Directories (open only) Disk devices (Windows NT/2000 only) Files Mailslots Pipes HANDLE CreateFile( LPCTSTR lpFileName, // file name DWORD dwDesiredAccess, // access mode DWORD dwShareMode, // share mode LPSECURITY_ATTRIBUTES lpSecurityAttributes, // SD DWORD dwCreationDisposition, // how to create DWORD dwFlagsAndAttributes, // file attributes HANDLE hTemplateFile // handle to template file ); Success, Arjan
Mar 14 2001