Can I use WMI to read a printer spool file - wmi

My client has an old DOS-based application which sends formatted output to a printer. I have disabled printing so spooled files remain in the print queue. I would like to pick up these spool files and convert them to PDF format (then ideally delete them). Is this possible using WMI?
BTW I cannot change anything within the application which produces the printed output.
I would like to do this as part of an existing Visual Foxpro utility which I support.

The formatted output of the application will be ASCII text with embedded Epson or PCL printer codes. A Windows virtual PDF printer (or other printer drivers) doesn’t support such data stream. You would have to use the Generic Text Only printer driver and save the output to file. Or a DOS-to-Windows print processor like DOSprn, or a DOS emulator like vDos, that converts the ASCII text for a Windows printer driver.

There are many complications, but most of them are covered here. In particular see:
Force JobID in Spoolfile names
When is RAW used?
Depending on the application, driver, and other factors, the format of the spool files will be EMF, XPS or a "raw" PDL like PostScript, PCL, PCL6 etc. EMF is a bit old in the tooth now, but you can find modern components to render most PDLs. If you can get the driver you're using to spool to PDF then you're done.
Since the DOS application successfully prints to an HP 4200 (which supports these languages: HP GL/2, HP PJL, PCL 5E, PCL 6, PostScript 3), the spool file is likely to be ASCII with control codes or PCL escape codes. You should open the spool file in a hex editor and have a look. They are usually stored in "C:\Windows\System32\spool\PRINTERS" as SPL files.
You might be able to use GhostScript depending on which licences you're ok with. E.g. for PCL to PDF see this (old) question and its answers - search for more recent ones.
Other commercial options include Aspose for EMF to PDF. These are the kinds of tools you need to seek out and evaluate for your particular use cases.
WMI can delete print jobs. E.g. on the command line:
wmic printjob where jobid=<jobnumber> delete

If it's a HP the files are (as everyone else above has said) in PCL. There is a command line utility here that converts PCL to PDF. To quote:
This page offers two almost identical utilities that create PDF output from PCL "print files." Both use GhostPCL by Artifex (released under the GNU General Public License) as the engine that performs the conversion.
So you could do it from Visual FoxPro by building a command line to run the EXE with the relevant parameters and executing it with (for example) Windows Scripting Host:
lcExe = "full\path\to\winpcltopdf.exe"
lcCommandLine = "myinputfile.pcl myoutputfile.pdf"
loWshShell = CreateObject("WScript.Shell")
lnProcessReturnCode = loWshShell.Run(lcExe + " " + lcCommandLine, 1, .t.)

Related

How to read FLASH contents on a Raspberry Pico?

The process to transfer a .UF2 image of an application onto a Raspberry PICO device is well-documented and works as advertised.
Are there ways to flash multiple files (or contents, since there is no file system on the PICO) and then read them from the application that was flashed along with it?
I need to have my app (the .UF2 image) read the data that I am supplying in the additional files along with it.
Is this even possible using the C++ SDK tools, and how would one go about it? I am looking for something simpler than using a file system on the PICO (like LittleFS).
Littlefs is a library for adding file system support to embedded devices. It was originally developed by ARM and there are ports for both arduino and baremetal to interface directly with the RP2040. It is incredibly well documented although it does have some limitations(i.e. file names shorter than 31 characters). Here is probably a good place to start if you are using the Arduino IDE.

What is the Windows API to use a disc as a Live File System?

I have developed a CD Burning Application with C++ using Windows IMAPI.
However, now I want my disc to be able to function like Live File System (Like USB).
Basically, I want to have the capabilities that Windows Explorer provide in below screen shot:
May I know if there is any Windows API I can use to be able to achieve this?
The "Like a USB flash drive" file system is also called Live File System.
Live File System is the term Microsoft uses to describe the packet writing method of creating discs in Windows Vista and later, which allows files to be added incrementally to the media. These discs use the UDF file system.
Older Windows versions do not have support for reading the latest UDF versions. If users create DVD/CDs in Windows Vista using UDF 2.50, these may not be readable on other systems, including Windows XP and older (pre-Mac OS 10.5) Apple systems unless a third-party UDF reader driver is installed. To ensure compatibility of disks created on Windows Vista, UDF 2.01 or lower should be selected.
Live file system is based on InCD technology developed by Nero AG for Microsoft Windows.
InCD is a packet writing software developed by Nero AG for Microsoft Windows.
InCD allows optical discs to be used in a similar manner to a floppy disk. The user can drag and drop files to and from the disk using Windows Explorer, or open and save files on the disk directly from application programs.[2]
InCD formats media, and writes to Universal Disk Format. Systems which do not support UDF (such as Windows 98) will only present a HTML page (stored on the disk, outside the UDF part), explaining the problem and linking to a free UDF reader software.
As stated above Live file system uses FsiFileSystemUDF internally.
Following are the file systems supported by IMAPI:
FsiFileSystemNone The disc does not contain a recognized file system.
FsiFileSystemISO9660 Standard CD file system.
FsiFileSystemJoliet Joliet file system.
FsiFileSystemUDF UDF file system.
FsiFileSystemUnknown The disc appears to have a file system, but the layout does not match any of the recognized types.
Live file system works in following way:
However, if you’re using a non-rewritable disc, you can still only write to every area of the disc once. For example, if you burn a 50 MB file to the disc, then delete it later and burn another 50 MB file to the disc, the total space used on the disc is still 100 MB. The original 50 MB you burned to the disc is still present, although it’s been marked as deleted and won’t be shown when you use the disc.
If you’re using a rewritable disc with the Live File System, space used by deleted files will be erased immediately and the space will be reclaimed. This is a big advantage for rewritable discs – you can write to them and delete files as if you were writing to a USB flash drive, without having to perform a clunky full-disc erase operation every time you want to erase some files.
The same happens with FsiFileSystemUDF supported by IMAPI. FsiFileSystemUDF is most advanced and supported by most of the devices. So, you may consider using FsiFileSystemUDF file system.
USB Like behavior is achieved by allowing to writing same disk more than once. This can be achieved by not closing/finalizing the disk. This way, when each time you attempt to re-write new (or old) data to disk, old data is erased - space is lost on non-rewritable disk - data is written freshly. You may read more about finalizing the disk here.
Please note, I am not suggesting that FsiFileSystemUDF is exactly the same as Live File System. As mentioned above, Live file system is not developed by Microsoft and not supported by IMAPI.

Reading Outlook Express XP-32 DBX format and XP-64 DBX format

I use format/sources from https://www.infobyte.hr/oedbx/ to read OE6 DBX files and it works just fine. On 32-bit version of OE6, on Windows XP 32-bit.
On 64-bit Windows XP it seems that OE6 is using slightly different DBX format. It is odd enough because it is otherwise looking the same. The format is not completely different, just slightly, but enough that my reader can't read all of the files. It can read some DBX files but not all.
Is there a more complete documentation, more complete source for reading DBX files or documented difference between the two formats I can use to adjust my code to read both formats?
Of course, I can resort to reading it using OE/Windows Mail API but then DBX files can't be read on Windows 8 or Windows 7, only on Windows XP or Vista. This is my last resort solution if I can't make the reader compatible with 64-bit format.
After some examination I found no documentation on 64-bit format and decided to read 64-bit format using IStoreFolder interface (http://msdn.microsoft.com/en-us/library/ms710250%28v=vs.85%29.aspx). Good thing is that this interface also supports reading messages from Windows Mail. Bad thing is that it does not read all database fields properly (e.g. Watch and Account cannot be read), but at least the basic message/folder data can be extracted.

Linux print document to standard output or file

Is there any possibility to print document in Linux to standard output, formed for later sending directly to printer's queue and is there any generic format, suitable for all network printers?
Indeed, I do need to do the following process:
1. Print doc to the above mentioned formatted output (or file).
2. Transfer this to the remote device.
3. Send this to the Printer.
Some more details: Document is printed on one hardware Server, being sent to some Device with no printer Driver (so, it Detects printer as a Network device) and then send the Document to queue as a TCP client.
I would recommend that you print to PostScript or PDF. For example, here is a CUPS PDF printer. Another way to do it would be to write your own backend. Here is an example of how to write a CUPS backend in a shell script.
There is no format all printers understand, other than plain text of course. Which has nothing to do with Linux, really. But if you're willing to include some processing in step 3, sure, just write pdf or postscript and send that through the standard printer queue.
is there any generic format, suitable for all network printers?
No. Some printers will understand PostScript, others will understand PCL, and others will require other specific formats. There is no "lingua franca" in the printer world as far as hardware is concerned, which is why you must go through a print manager.
Is there any possibility to print document in Linux to standard output, formed for later sending directly to printer's queue
Since there is no common printing format, you can't make such a document. The simplest thing on Linux is to print either to PostScript or to PDF, and feed that again to CUPS (or any other print manager you use) when you want to output on a specific printer.

how to get MAC aaddress and Modified date of text file in C++ builders

how to get mac address of pc and modified date of text file in runtime program,using C++ builder,if both matches red color rectangle should come,or else green colour...as an output
For the MAC address, look at the Win32 API GetAdapterAddresses() and similar functions. Keep in mind that a PC can have multiple MACs available, one for each installed network adapter if the PC is connected to multiple networks.
For the file date, look at the Win32 API GetFileTime() or FindFirstFile() functions, or the VCL FindFirst() function (which uses FindFirstFile() internally.