Charelle
14 years agoNew Contributor
How to get Printer job information
Hi,
I want test if the job I printed with my application is sent in the queue of my local printer. I want to know the document name and how many page is that document.
I found that I could probably use WMI or Win32API to get that information.
I found some vbscript samples to access to printers with WMI. I translated in jscript:
var strComputer = "."
objWMIService = GetObject("winmgmts:" + "{impersonationLevel=impersonate}!\\" + strComputer + "\root\cimv2");
colInstalledPrinters = objWMIService.ExecQuery("Select * from Win32_Printer");But the GetObject gave me that error:
OLE error 80041021
Then I tried to replace the GetObject by the testComplete extension object : WMI.Service
I think it works(It doesn't give error), but now I would like to know how to iterate in jscript through colInstalledPrinters[Object] to get the information I need.
Do you have some code sample with WMI or Win32API?
Or do you see a better way to test printing jobs?
Best regards,
Charelle
I want test if the job I printed with my application is sent in the queue of my local printer. I want to know the document name and how many page is that document.
I found that I could probably use WMI or Win32API to get that information.
I found some vbscript samples to access to printers with WMI. I translated in jscript:
var strComputer = "."
var objWMIService = GetObject("winmgmts:" + "{impersonationLevel=impersonate}!\\" + strComputer + "\root\cimv2");
objWMIService = GetObject("winmgmts:" + "{impersonationLevel=impersonate}!\\" + strComputer + "\root\cimv2");
var colInstalledPrinters = objWMIService.ExecQuery("Select * from Win32_Printer");
colInstalledPrinters = objWMIService.ExecQuery("Select * from Win32_Printer");But the GetObject gave me that error:
OLE error 80041021
Then I tried to replace the GetObject by the testComplete extension object : WMI.Service
I think it works(It doesn't give error), but now I would like to know how to iterate in jscript through colInstalledPrinters[Object] to get the information I need.
Do you have some code sample with WMI or Win32API?
Or do you see a better way to test printing jobs?
Best regards,
Charelle