You can enumerate printers in the system by using some Win32API calls this way (here I am filling a listbox with printer names on a button callback):
int CVICALLBACK EnumeratePrinters (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int error = 0;
int i, numPrt, needed;
PRINTER_INFO_1 *pi = NULL;
char *z = NULL;
if (event != EVENT_COMMIT) return 0;
//BOOL EnumPrinters(
// DWORD Flags, // printer object types
// LPTSTR Name, // name of printer object
// DWORD Level, // information level
// LPBYTE pPrinterEnum, // printer information buffer
// DWORD cbBuf, // size of printer information buffer
// LPDWORD pcbNeeded, // bytes received or required
// LPDWORD pcReturned // number of printers enumerated
//);
// Get required memory size
EnumPrinters (
PRINTER_ENUM_LOCAL, // enumerate local printers
NULL, // name of printer object
1, // general printer info
NULL, // printer information buffer
0, // size of printer information buffer
&needed, // bytes required
NULL // number of printers enumerated
);
// Allocate memory
z = malloc (needed);
memset (z, 0, needed);
// Enumerate printers
if (!EnumPrinters (
PRINTER_ENUM_LOCAL, // enumerate local printers
NULL, // name of printer object
1, // general printer info
z, // printer information buffer
needed, // size of printer information buffer
&needed, // bytes required
&numPrt // number of printers enumerated
)) {
MessagePopup ("Error", "Error in EnumPrinters.");
error = GetLastError ();
goto Error;
}
// Allocate structured memory
pi = calloc (numPrt, sizeof (PRINTER_INFO_1));
memcpy (pi, z, numPrt * sizeof (PRINTER_INFO_1));
for (i = 0; i < numPrt; i++) {
InsertListItem (panel, PANEL_LISTBOX, -1, pi[i].pName, i);
}
SetInputMode (panel, PANEL_PRINT, 1);
Error:
if (z) free (z);
if (pi) free (pi);
return 0;
}
The list of printers can be shown in a "options" panel where the user can select the printer to be used, next you can print with that printer this way:
int CVICALLBACK PrintSome (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int idx;
char name[64];
if (event != EVENT_COMMIT) return 0;
GetCtrlIndex (panel, PANEL_LISTBOX, &idx);
GetLabelFromIndex (panel, PANEL_LISTBOX, idx, name);
SetPrintAttribute (ATTR_PRINTER_NAME, name); // Specify which printer to use
SetPrintAttribute (ATTR_PRINT_AREA_WIDTH, VAL_INTEGRAL_SCALE);
SetPrintAttribute (ATTR_PRINT_AREA_HEIGHT, VAL_USE_ENTIRE_PAPER);
PrintPanel (panel, "", 1, VAL_FULL_PANEL, 1);
return 0;
}
Nevertheless, this is somewhat not intuitive and you need to dig and study some of Win32APIs to obtain it. You may want to support this CVI idea for an independent command that displays the print dialog.