Re: Oracle Reports Designer - Windows Default Printer
Date: Thu, 30 Dec 1999 09:03:54 +0100
Message-ID: <84f445$19a23$1_at_reader2.wxs.nl>
Hello Scott,
below you will find the code I use to get the default printer from the
windows registry.
(Sorry about the layout, caused by copy/paste)
You need to attach the library D2KWUTIL.PLL as well, which you can find on
your Oracle-Developer cd.
This library uses a dll called D2KWUT32.DLL. I'm not sure but I think
there's a NT and a W95/W98 version!!
Arie Mars
arie_at_pca-online.nl
/*
** Name : get_default_printer
- Description: Get the name of the default printer from the registry.
**
- In : -
- : -
- Out : -
- Return : VARCHAR2 Name of the printer. On WinNT (not on W95/W98) this
- is a complete UNC-path, if it is a network printer.
**
- History : 07-10-1999 AM - Creation. */
FUNCTION GET_DEFAULT_PRINTER RETURN VARCHAR2 IS
prt_name varchar2(180); -- name of printer
prt_con varchar2(100); -- printer's connection (network resource or
port)
win_ver varchar2(15); -- "Windows 95", "Windows 98" or "" (windows nt)
str_from number;
- Returns name to be passed to the oracle-report DESNAME property
- Note: D2KWUTIL package must be attached
- With help from: Olli-Pekka Tarna E-Mail: ollipekka.tarna_at_akermar.com
- He wrote a function which also extracted the friendly name for network-printers:
- see registry-key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\
- Providers\LanMan Print Services\Servers\NETWORKNAME\Printers\PRINTERNAME\Share Name
- where NETWORKNAME and PRINTERNAME are extracted from key used below
- Only for WIN NT
BEGIN
win_ver :=
WIN_API_ENVIRONMENT.READ_REGISTRY('HKEY_LOCAL_MACHINE\Software\Microsoft\'
||
'Windows\CurrentVersion', 'Version', FALSE); IF UPPER(win_ver) = 'WINDOWS 95' OR UPPER(win_ver) = 'WINDOWS 98' THEN -- prt_name :=
WIN_API_ENVIRONMENT.READ_REGISTRY('HKEY_CURRENT_CONFIG\System\CurrentControl Set\' ||
-- 'Control\Print\Printers', 'Default', FALSE); prt_name :=
WIN_API_ENVIRONMENT.READ_REGISTRY('HKEY_LOCAL_MACHINE\Config\0001\System\Cur rentControlSet\' ||
'Control\Print\Printers', 'Default', FALSE); ELSE prt_name := WIN_API_ENVIRONMENT.READ_REGISTRY('HKEY_CURRENT_USER\Software\Microsoft\' || 'Windows NT\CurrentVersion\Windows', 'Device', FALSE); -- extract first part, containing the name IF length(prt_name) > 0 THEN str_from := instr(prt_name,',',1,1)-1; prt_con := substr(prt_name,1,str_from); prt_name := prt_con; -- port name ELSE prt_name := null; END IF;
END IF; RETURN prt_name;
EXCEPTION
WHEN no_data_found THEN
RETURN NULL;
END;
Received on Thu Dec 30 1999 - 09:03:54 CET