c++ - Output to USB printer
- "Heinz-Peter Nuettgens" <hnuettgens t-online.de> Mar 14 2001
- Arjan Knepper <jak01 pop3.NL.net> Mar 14 2001
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
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