Tracy,

FYI, on my development system (VFP 9 SP2, Win7Pro)...
If I blank the default printer setting on
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device then the default green-check does not show in the Devices and Printers dialogue, and
    Set('printer',1)  returns blank (not null, blank character)
    Set('printer',2)  returns blank
    Set('printer',3)  returns error "Printer is not ready"

With the registry entry valid, 1=blank, 2=PrinterName, 3=Printername as expected. I knocked together a little VFP EXE file, ran it on both my system and the one that trouble today and it does seem to respect the above registry entry for HKCU as the response for the Set('printer',X) functions. So, I could easily test for those in VFP, then restore the appropriate printer as default.

FWIW, "set printer to default" does not throw an error in development but does in runtime, when the default printer is missing (un-set). At least for me.

So test Sys('printer',2) for blank after 1958 is triggered, then set it to the appropriate default printer...which is stored in a table for easier maintenance.

In fact, thanks to Sergey Berezniker, it's easy...

    local lcPrinter
    lcPrinter = 'Printername'
    oWSC = createobject('WScript.Network')
    TRY
        oWSC.SetDefaultPrinter(lcPrinter)
    CATCH
        * report and process error
    ENDTRY

God I love my job! Maybe even someday I'll find out what started this mess.

Thanks, Tracy!

Mike Copeland

Tracy Pearson wrote:
Does finding out what the default printer if is cause an error? If it is 
different then the stored value, the system can be self updating. If it is 
blank, or an unknown device, it can make adjustments.

On October 10, 2015 11:49:36 PM EDT, Mike Copeland <[email protected]> wrote:
Actually, Brant, that's a great idea because it would make maintenance
a
lot easier. Printers do get shuffled (and renamed/reinstalled) from
time
to time without my knowledge and it would allow me to group
workstations
to a single printer. My prior thought was to store the default printer
name in an INI file that my app uses to store the IP address for the
data server. Doing it my way requires 150 (or at least a bunch) of
system accesses and updates, along with future individual updates.
Using
a table I can define clusters, assign the workstation IP address to a
cluster and assign a printer to a cluster. Kind of an abstraction
layer.
If a printer changes, then the only update is to update the name of the

printer for the affected cluster.

Thanks for the brain cycles!

Mike

Brant E. Layton wrote:
Hi Mike,

A thought to help with the default printer issue.

Since you are making changes to work around the problem, maybe
include
this?

A new table containing the machine and correct default printer.

You could define a record for each computer when you find that there
is a default printer set.  Or, you may already have a record
somewhere
of the computers and the printer they 'should' be using.
|


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to