• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

select printer

In my program I want to use a certain printer and the user should not be able to select one in the dialog. I want to do this in the sourcecode. I know how to disable the dialog but how about the printer selection ?
0
MarcoHelmers
Asked:
MarcoHelmers
1 Solution
 
chensuCommented:
How To Get and Set the Default Printer in Windows
http://support.microsoft.com/support/kb/articles/q135/3/87.asp 

How to Set the Default Printer Programmatically in Windows 95
http://support.microsoft.com/support/kb/articles/q140/5/60.asp 
0
 
MarcoHelmersAuthor Commented:
Both pages you mentioned only refer to setting the default printer. What I actually want to do is to set the printer only for the document my program prints just as if you would do it in the printing dialog. How can I do that ?
0
 
MarcoHelmersAuthor Commented:
If you do not know please tell me ...
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
chensuCommented:
Sorry. Look into the Win32 sample "Printer: Printing". It does what you want.
0
 
MarcoHelmersAuthor Commented:
Can anyone else tell me how it has to be done.
0
 
bwilkins081898Commented:
I am familiar with windows printing functions.  Question...
Does you program know what the windows name is for the printer
you are trying to print to?

0
 
MarcoHelmersAuthor Commented:
Yes, I do know the windows name for the printer. Do you know what I have to do ?
0
 
MarcoHelmersAuthor Commented:
Please help ...
0
 
chensuCommented:
Look into the Win32 sample "Printer: Printing".
0
 
MarcoHelmersAuthor Commented:
that answer does not content me but ok ...
if you want the points ... lock the question...
0
 
chensuCommented:
You may wait for a while to see whether there are better answers.
0
 
BonevCommented:
here is a small function that retrieves a list of all installed printers:

void GetPrinterNameList(CStringArray& printerList)
{
      PRINTER_INFO_2* p;
      DWORD nbytes;
      DWORD nprinters;
      int i;

      EnumPrinters( PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &nbytes, NULL);
      p = (PRINTER_INFO_2*)new char[nbytes];

      EnumPrinters( PRINTER_ENUM_LOCAL, NULL, 2, (unsigned char*)p, nbytes, &nbytes, &nprinters );

      printerList.RemoveAll();
      for( i = 0; i < nprinters; i++ )
            printerList.Add( p[i].pPrinterName );

      delete (char*)p;
}                                                                     


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now