1. Yet Another different hack at getDefaultPrinter()
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Oct 10, 2003
- 384 views
Thanks to everyone testing this, it's now a humbling 4:0 to the giggling guys and gals at Gates gaff. ...And for my fifth attempt, I present the GetProfileStringA method: Pete PS Derek, Bob, you've already tested this for me! -- code follows -- -- GetDefaultPrinterName -- Author Pete Lomax 9/10/03 --=20 include dll.e include machine.e constant k32=3Dopen_dll("kernel32.dll"), xGetProfileStringA=3Ddefine_c_func(k32,"GetProfileStringA", {C_POINTER,C_POINTER,C_POINTER,C_POINTER,C_LONG},C_LONG), win=3Dallocate_string("windows"), dev=3Dallocate_string("device"), default=3Dallocate_string(",,,") global function GetPrintName() atom len, res integer maxlen sequence pname maxlen=3D40 while 1 do res=3Dallocate(maxlen) len=3Dc_func(xGetProfileStringA,{win,dev,default,res,maxlen}) if len<maxlen+1 then exit end if free(res) maxlen*=3D2 end while pname=3Dpeek({res,len}) pname=3Dpname[1..find(',',pname)-1] free(res) return pname end function printf(1,"\"%s\"\n",{GetPrintName()}) if getc(0) then end if
2. Re: Yet Another different hack at getDefaultPrinter()
- Posted by Louis at cwshop.com Oct 10, 2003
- 399 views
This works on my Win2K SP4 system. Though, I am a bit worried about the= while 1 loop. This is the kind of thing that crashes computers when= something unexpected happens. Louis. *********** REPLY SEPARATOR *********** On 10/10/2003 at 11:19 AM Pete Lomax wrote: > > >Thanks to everyone testing this, it's now a humbling 4:0 to the >giggling guys and gals at Gates gaff. > >...And for my fifth attempt, I present the GetProfileStringA method: > >Pete >PS Derek, Bob, you've already tested this for me!
3. Re: Yet Another different hack at getDefaultPrinter()
- Posted by Juergen Luethje <j.lue at gmx.de> Oct 11, 2003
- 425 views
Pete wrote: > Thanks to everyone testing this, it's now a humbling 4:0 to the > giggling guys and gals at Gates gaff. > > ...And for my fifth attempt, I present the GetProfileStringA method: > > Pete > PS Derek, Bob, you've already tested this for me! > > -- code follows > -- > -- GetDefaultPrinterName > -- Author Pete Lomax 9/10/03 [code snipped] Windows 98/1st ed., 3 printers installed: Your code correctly shows the name of the default printer. Regards, Juergen