Select Default Printer - From Api

A veces es necesario saber cual es la impresora predeterminada, para enviar la
impresi?n. Con el uso de este c?digo podr?s enviar a la impresora por default
o tomar esta para alg?n uso en particular.


Sometimes it is necessary to know which is the predetermined printer, to send
the impression. With the use of this code will be able to send to the printer
by default or to take this for some I use in particular.
Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (Byval hKey
As Long, Byval lpSubKey As String, Byval dwReserved As Long, Byval
samDesired As Long, phkResult As Long) As Long
Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA"
(Byval hKey As Long, Byval lpValueName$, Byval lpdwReserved As Long, lpdwType
As Long, lpData As Any, lpcbData As Long) As Long
Declare Function RegCloseKey Lib "advapi32" (Byval hKey As Long) As Long



Sub Click(Source As Button)
Dim PName As String
Dim WorkSpace As New NotesUIWorkSpace
Dim UIDoc As NotesUIDocument
Dim Doc As NotesDocument
Set UIDoc = WorkSpace.CurrentDocument
Set Doc = UIDoc.Document
Doc.txtPrinterDefault = GetCurrPrinter()
End Sub


Function GetCurrPrinter() As String
Const HKEY_CURRENT_CONFIG = &H80000005
GetCurrPrinter = RegGetString$(HKEY_CURRENT_CONFIG,
"System\CurrentControlSet\Control\Print\Printers", "Default")
End Function




Function RegGetString$(hInKey As Long, Byval subkey$, Byval valname$)
Dim RetVal$, hSubKey As Long, dwType As Long, SZ As Long
Dim R As Long

RetVal$ = ""
Const KEY_ALL_ACCESS = 0
Const ERROR_SUCCESS = 0
Const REG_SZ = 1

R = RegOpenKeyEx(hInKey, subkey$, 0, KEY_ALL_ACCESS, hSubKey)
If R <> ERROR_SUCCESS Then Goto Quit_Now

SZ = 256
v$ = String$(SZ, 0)
R = RegQueryValueEx(hSubKey, valname$, 0, dwType, Byval v$, SZ)
If R = ERROR_SUCCESS And dwType = REG_SZ Then
RetVal$ = Left$(v$, SZ)
Else
RetVal$ = "--Not String--"
End If
If hInKey = 0 Then R = RegCloseKey(hSubKey)
Quit_Now:
RegGetString$ = RetVal$
End Function
This was first published in November 2000

Dig deeper on Domino Resources

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close