- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Enumerate printers
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Enumerate printers
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
HI @michalksweda ,
There is no direct installscript function to retrieve it,but it can be achieved by implementing Microsoft's function "EnumPrinters" by adding necessary header files to installscript
The below sample article can help you with how to add Windows API to installscript.
EnumPrinters :https://docs.microsoft.com/en-us/windows/desktop/printdocs/enumprinters
Add Winspool.h as a header to it.
Thanks,
Jenifer
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
I'm doing something wrong as I get the error:
MSI (c) (8C:08) [16:34:43:534]: Leaked MSIHANDLE (76) of type 790541 for thread 14544 MSI (c) (8C:08) [16:34:43:534]: Note: 1: 2769 2: PopulatePrinterSelectionComboBoxCustomAction 3: 1
Info 2769. Custom Action PopulatePrinterSelectionComboBoxCustomAction did not close 1 MSIHANDLEs.
CustomAction PopulatePrinterSelectionComboBoxCustomAction returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 16:34:43: PopulatePrinterSelectionComboBoxCustomAction. Return value 3.
My code is
// structure for EnumPrintersA from winspool.drv typedef PRINTER_INFO_5 begin LPSTR pPrinterName; LPSTR pPortName; LONG Attributes; LONG DeviceNotSelectedTimeout; LONG TransmissionRetryTimeout; end; // helper functions used in PopulatePrinterSelectionComboBoxCustomAction located in Windows installation // winspool.drv EnumPrintersA prototype INT winspool.EnumPrintersA(LONG, BYREF STRING, LONG, BYREF POINTER, LONG, BYREF LONG, BYREF LONG);
function PopulatePrinterSelectionComboBoxCustomAction(hMSI)
NUMBER nResult;
STRING svName;
STRING svPortName;
STRING szMsg;
STRING svPrinterName;
STRING svTarget;
NUMBER nvByteCopy;
NUMBER nvNumberOfDevices;
begin
svName = "";
svPortName = "";
// Load winspool.drv so you can call EnumPrintersA
nResult = UseDLL("winspool.drv");
if (nResult < 0 ) then
return ERROR_FUNCTION_FAILED;
endif;
// Windows API call builds list of installed printers
nResult = EnumPrintersA(2, svName, 5, pPointer, 500, nvByteCopy, nvNumberOfDevices);
At the EnumPrintersA, the function call crashes the installer. What I'm doing wrong?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Running printer inventory has the drawback of being dependent on the systems that are online at the time of the report. It can take a long time to get everyone to report back with accurate printer information at this site if you manage a fleet of distant users with direct attached printers. Either set up a script to run in the background with the hopes of collecting all remote users, or put a script on their system that reports back once a day or something similar.
![](/skins/images/CC38E504FC9E1309DC48ACFEB4925670/responsive_peak/images/icon_anonymous_message.png)