Kbase 15796: How to identify the Windows default printer from the 4GL
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/05/1998 |
|
How to identify the Windows default printer from the 4GL
How To Identify the Windows Default Printer in the 4GL
In V8, the Report Builder Deployment guide describes how to
use the _predef.r file to identify the current default
printer (chapter 2.2).
The _prdef.r file is not shipped with version 7. The source
code for this procedure in included in this knowledge-base.
Although Progress is supplying this source code, it is an
unsupported procedure. You are welcome to use it and modify
it to suit your needs, but we do not support is as a Progress
product. This code works for the 16-bit versions of Progress.
To see how to do this for 32-bit Progress, see the section below
labeled Code For 32-bit.
Use the following command in the Progress 4GL application.
RUN path/_prdef.p(OUTPUT printer-name, OUTPUT port-name,
OUTPUT success)
"success" is a logical variable that gets assigned a TRUE
value if Progress returns a string of zero or more characters
and a FALSE value if no string was returned.
----------
define output parameter def-printer as character no-undo.
define output parameter def-port as character no-undo.
define output parameter success as logical no-undo.
procedure GetProfileString external "KRNL386.EXE" :
define input parameter section as character.
define input parameter item as character.
define input parameter default-string as character.
define output parameter result as memptr.
define input parameter result-size as short.
define return parameter result-length as short.
end procedure.
define variable result as memptr no-undo.
define variable length as integer.
define variable temp as character.
set-size (result) = 1024.
run GetProfileString ("windows", "device", "", output result,
1023, output length).
def-printer = "".
def-port = "".
if length <= 0 then
success = no.
else do:
temp = get-string (result, 1).
def-printer = entry (1, temp).
def-port = entry (3, temp).
if def-printer > "" and def-port > "" then
success = yes.
else
success = no.
end.
set-size (result) = 0.
Code for 32-bit.
----------------
In Windows with Progress version 8.2A and later, you can find the
printer by using the following session attributes:
SESSION:PRINTER-NAME
SESSION:PRINTER-PORT
If you want to run 4gl code that finds the same information as in the
16-bit versions, run the following instead of the _prdef.p shown
above:
define output parameter def-printer as character no-undo.
define output parameter def-port as character no-undo.
define output parameter success as logical no-undo.
procedure GetProfileStringA external "KERNEL32.DLL" :
define input parameter section as character.
define input parameter item as character.
define input parameter default-string as character.
define output parameter result as memptr.
define input parameter result-size as long.
define return parameter result-length as long.
end procedure.
define variable result as memptr no-undo.
define variable length as integer.
define variable temp as character.
set-size (result) = 1024.
run GetProfileStringA ("windows", "device", "", output result,
1023, output length).
def-printer = "".
def-port = "".
if length <= 0 then
success = no.
else do:
temp = get-string (result, 1).
def-printer = entry (1, temp).
def-port = entry (3, temp).
if def-printer > "" and def-port > "" then
success = yes.
else
success = no.
end.
set-size (result) = 0.
Progress Software Technical Support Note # 15796