Using Win32 functions in Visual FoxPro Image Gallery
Printing and Print Spooler
..msdn
AddPort
AddPrinter
ClosePrinter
ConfigurePort
ConnectToPrinterDlg
DeletePort
DeviceCapabilities
DocumentProperties
EndDoc
EndPage
EnumForms
EnumJobs
EnumPorts
EnumPrinterData
EnumPrinterDrivers
EnumPrinters
EnumPrintProcessorDatatypes
EnumPrintProcessors
Escape
FindClosePrinterChangeNotification
FindFirstPrinterChangeNotification
FindNextPrinterChangeNotification
FreePrinterNotifyInfo
GetDefaultPrinter
GetPrinter
GetPrinterData
GetPrinterDriverDirectory
GetPrintProcessorDirectory
OpenPrinter
PrinterProperties
SetDefaultPrinter
SetJob
SetPrinter
StartDoc
StartPage
Code examples:
Setting default printer
SetDefaultPrinter
..msdn    Add comment     W32 Constants      Translate this page
Sets the printer name of the default printer for the current user on the local computer.
Code examples:
Setting default printer
Declaration:
BOOL SetDefaultPrinter(
    LPCTSTR pszPrinter  // default printer name
);
FoxPro declaration:
DECLARE INTEGER SetDefaultPrinter IN winspool.drv;
    STRING pszPrinter

Parameters:
pszPrinter
[in] Pointer to a null-terminated string containing the default printer name. For a remote printer, the name format is \\server\printername. For a local printer, the name format is printername.
Return value:
If the function succeeds, the return value is a nonzero value.
Usage:
cPrinter = GetPrinter()
IF NOT EMPTY(m.cPrinter)
    = SetDefaultPrinter(m.cPrinter)
ENDIF
My comment:
If pszPrinter is NULL or an empty string, SetDefaultPrinter does nothing if there is already a default printer. However, if there is no default printer, SetDefaultPrinter sets the default printer to the first printer, if any, in an enumeration of printers installed on the local computer.

The function is as simple as it is and hardly requires a sample code. If SetDefaultPrinter returns 0, call GetLastError to get an extended error information.

#DEFINE ERROR_INVALID_PRINTER_NAME 1801

Also consider using Windows scripting objects:
ws = CreateObject("WScript.Network")
ws.SetDefaultPrinter("\\MyServer\HP5")

See also: GetDefaultPrinter, EnumPrinters, PrinterProperties.

* * *
As you prpobably noticed the Printer And Faxes OS Window immediately reflects a change in default printer. Here is a screen copy of a tap put on the messages received by a member of this window subtree (window class CtrlNotifySink).



Each successful SetDefaultPrinter call broadcasts the WM_SETTINGCHANGE message.

Word Index links for the SetDefaultPrinter :
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
Created: 2005-04-26 15:30:17
Modified: 2008-04-16 13:33:59
Visited in last 7 days: 21
User Contributed Notes:
There are no notes on this subject.


Copyright 2001-2017 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.38), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.198.2.110)
11 sec.Example: 'How to change display settings: screen resolution, screen refresh rate'
24 sec.All Functions
36 sec.Function: 'getnameinfo'
Function group: 'Windows Sockets 2 (Winsock)'
47 sec.
Function group: 'Security'
1 min.Function: 'GetVolumeInformation'
Function group: 'File System'
1.15 min.
1.35 min.All Functions
1.55 min.Links
1.75 min.Function: 'ReplaceFile'
Function group: 'File Management'
1.92 min.Function: 'GdipCreateMatrix'
Google
Advertise here!