Problems Setting the Default printer with Win32 API SDK 
Author Message
 Problems Setting the Default printer with Win32 API SDK

Hi

I have the following code segment in a program thatchanges the default
printer.  My problem, is that in NT, a (one particular) 16-bit
application that I use, will recognize a change to the default printer
if it is done via the printer icon in the printers folder but it will
not recognize the change performed with this code.

If I change the printer with this, nothing will print at all from that
app, until I set the default printer with the printer icon.

Any idea what the printers icons do when they perform the Set as
Default?

Regards

Tim Legge

else if (osver==cWinNT)
        {
        EnumPrinters (PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS,
                NULL, 2, "", 0,  &dwNeeded, &dwReturned);
        ppinfo2 = (LPPRINTER_INFO_2) HeapAlloc (GetProcessHeap(),      
                HEAP_ZERO_MEMORY, dwNeeded);
        if (ppinfo2)
        {

bErr=EnumPrinters(PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS,
                         NULL, 2, (LPBYTE) ppinfo2, dwNeeded,
                         &dwNeeded, &dwReturned);
                if(!bErr)
                {
                        MessageBox(HWND_DESKTOP,
                                "Enumerating Printers Failed" ,
                                 "Change Default Printer", MB_OK);
                        return FALSE;
                }
                sprintf(tmpPrinter, "%s,%s,%s",
                         ppinfo2[iMenuItemSelected].pPrinterName,
                         ppinfo2[iMenuItemSelected].pDriverName,
                         ppinfo2[iMenuItemSelected].pPortName);
                WriteProfileString("windows", "device", tmpPrinter);
                SendMessageTimeout(HWND_BROADCAST, WM_WININICHANGE,
                         0L, 0L, SMTO_NORMAL, 1000, NULL);
                }
        }



Mon, 05 Aug 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Windows Default Printers and Default Printer Setups

2. win32 sdk api

3. Difference between the Win32 API and Platform SDK

4. Marshal Win32 API EnumPorts Printer

5. Set Default Printer

6. Set default printer

7. how to Set Default Printer

8. Q: How to set default printer bin?

9. Help : How to set the default printer

10. Setting the Default Printer

11. how to Set Default Printer

12. Changing the default printer settings for the entire system

 

 
Powered by phpBB® Forum Software