>I would like to know how I can set any installed Windows Printer as the current printer for VFP and for Windows, I used Getprinter but did not work. Is very important, I am finishing an application and this one is the last thing to terminate it. Tia
>
It's actually pretty trivial to do using APRINTERS(), and a registry key for the current user.
The registry key HKEY_CURRENT_CONFIG\System\CurrentControlSet\Control\Print\Printers contains the list of currently defined printers for the user logged into the system. Each defined printer is listed as a subkey; this list is returned by APRINTERS() in the first column of the two dimensional array.
In the Printers registry key itself, there's a Registry Value called Default; this is a string registry value, which contains the name of the current default printer. If you write the name of the printer that you want to use as the default printer in this resitry key value, VFP (and all other WinApps) will use that printer as the default printer for the user.
The FFC Registry class in VFP 6 has all the functionality needed to set this registry value; it uses the Win32 API calls and provides a consistent method for manipulating the registry. In earlier versions, you'll need to use the Win32 API calls ; there are classes that can be downloaded from UT's file section with the necessary functionality. In pseudocode, what needs to be done is:
Construct a list of printer names known to Windows
Pick the printer to use the default, and save the name WIndows uses to reference it
Open the registry key HKEY_CURRENT_CONFIG\System\CurrentControlSet\Control\Print\Printers using RegOpenKey()
Write the name of the desired printer to the registry value Default using RegSetValueEx()
Close the registry key using RegCloseKey()
Using the FFC, you'd use the OpenKey, SetKeyValue and CloseKey methods to open, write and close respectively.