PRINTING
Find the Desktop printer name
Try (from Frank's book):
'--- will run "as is" ---
CLEAR LOCAL MODE
DIM 63 printerName$
LOCAL FN getPrinterName$
resH& = FN GETSTRING(-8192)
LONG IF resH& = 0
printerName$ = "unknown"
XELSE
printerName$ = PSTR$([resH&])
CALL RELEASERESOURCE (resH&)
END IF
END FN = printerName$
a$ = FN getPrinterName$
WINDOW 1,"test",(0,0)-(160,160),_docNoGrow
PRINT a$
PRINT
INPUT ">";a$
END
'--- end of code ---
I started using that trick, then I found machines that had nothing in that string, and yet had 3 desktop printers all running at the same time! Also if
you need a job to go to a specific printer colour/lo-res/inkjet/imagesetter, you have to move up to tricks the big boys at Apple use :-)
<< Or the name of the current printer driver. The printer driver name is stored in the System file, but my app crashes when I go to open the System file's resources. >>
You don't need to open the System file's resources; they're already open and available to your app. FN GETSTRING(-8192) is the string you're after. Also:
h& = FN GETSTRING(-16413)
x$ = PSTR$([h&]) 'gets you the "machine name",
h& = FN GETSTRING(-16096)
x$ = PSTR$([h&]) 'gets you the user's network name,
mach%= FN GESTALT(_gestaltMachineType)
x$ = STR#(-16395,mach%) 'tells you what type of Mac you're running on,
etc.
(Um... be sure h& is not nil before calling PSTR... likewise mach%.)
Sorry I don't have the info on the desktop printer specifically... although the folder name _should_ be the -8192 result located in the desktop folder of the startup volume... but you're right, the user can change that name, and the change is definitely not reflected in -8192. I believe Jamin is right on in that you'll need some heavy calls to GESTALT. Jamin, I'd love to see that code!
|