Change "Document Defaults Settings" via MS-API's
(Last modified: 18Jan2002)
This document (10057746) is provided subject to the disclaimer at the end of this document.
goal
Change "Document Defaults Settings" via MS-API's
fact
You cannot change the "Document Defaults Settings" using the code below after the Novell Client for Windows NT has been installed.
symptom
Using a few APIs from Microsoft, to change those settings, the output of the problem is different if you are logged in with NT "Power User"-Rights and the NDPS-Printer is distributed automatically at the Login or if the Printer is installed manually or the User has Administrative Rights on the Workstation. Under this circumstances, the Settings can be changed trough those APIs.
1. You log in with Windows NT Power User Rights on a workstation. At that moment you get an automatically distributed NDPS-Printer. You cannot change the Document Defaults settings trough the API.
2. You log in with Windows NT Administrator Rights on a workstation. At that moment you get an automatically distributed NDPS-Printer. You can change the Document Defaults settings trough the API.
3. You log in with Windows NT Power User Rights on a workstation. You "manually" install a NDPS-printer trough "Add Printer ...". You can change the Document Defaults settings trough the API.
fact
**Api Declare ***
Private Declare Function OpenPrinter Lib "winspool.drv" _
Alias "OpenPrinterA" _
(ByVal pPrinterName As String, _
phPrinter As Long, _
pDefault As PRINTER_DEFAULTS) As Long
Private Declare Function GetPrinter Lib "winspool.drv" _
Alias "GetPrinterA" _
(ByVal hPrinter As Long, _
ByVal Level As Long, _
pPrinter As Any, _
ByVal cbBuf As Long, _
pcbNeeded As Long) As Long
Private Declare Function SetPrinter Lib "winspool.drv" _
Alias "SetPrinterA" _
(ByVal hPrinter As Long, _
ByVal Level As Long, _
pPrinter As Any, _
ByVal Command As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
Private Declare Function DocumentProperties Lib "winspool.drv" Alias "DocumentPropertiesA" (ByVal hwnd As Long, ByVal hPrinter As Long, ByVal pDeviceName As String, ByVal pDevModeOutput As Any, ByVal pDevModeInput As Any, ByVal fMode As Long) As Long
**Function**
Public Sub SetOrientation(NewSetting As Long, chng As Integer, ByVal frm As Form)
Dim PrinterHandle As Long
Dim PrinterName As String
Dim pd As PRINTER_DEFAULTS
Dim MyDevMode As DEVMODE
Dim Result As Long
Dim Needed As Long
Dim pFullDevMode As Long
Dim new_buffer() As Long
PrinterName = Printer.DeviceName
If PrinterName = "" Then
Exit Sub
End If
pd.pDatatype = vbNullString
pd.pDevMode = 0&
pd.DesiredAccess = PRINTER_ALL_ACCESS
Result = OpenPrinter(PrinterName, PrinterHandle, pd)
Result = GetPrinter(PrinterHandle, 2, ByVal 0&, 0, Needed)
ReDim new_buffer((Needed \ 4))
Result = GetPrinter(PrinterHandle, 2, new_buffer(0), Needed, Needed)
pFullDevMode = new_buffer(7)
Call CopyMemory(MyDevMode, ByVal pFullDevMode, Len(MyDevMode))
'Make changes
MyDevMode.dmDuplex = NewSetting
MyDevMode.dmCopies = 1
MyDevMode.dmPaperSize = 9
'MyDevMode.dmFields = DM_DUPLEX Or DM_ORIENTATION
MyDevMode.dmOrientation = chng
Call CopyMemory(ByVal pFullDevMode, MyDevMode, Len(MyDevMode))
Result = DocumentProperties(frm.hwnd, PrinterHandle, PrinterName, ByVal pFullDevMode, ByVal pFullDevMode, DM_IN_BUFFER Or DM_OUT_BUFFER)
Result = SetPrinter(PrinterHandle, 2, new_buffer(0), 0&)
Call ClosePrinter(PrinterName)
End Sub
symptom
There is no Error from the NT side or the customer`s application.
fact
If you do this via the Novell Printer Manager Wizard or via Control Panel or you are Administrator this works. When using RPM and Power User at the same time it doesn't work.
fix
This is a cosmetic issue and won't be resolved in the Novell code.
document
Document Title: | Change "Document Defaults Settings" via MS-API's |
Document ID: | 10057746 |
Solution ID: | NOVL29739 |
Creation Date: | 18Oct2000 |
Modified Date: | 18Jan2002 |
Novell Product Class: | netware client |
disclaimer
The Origin of this information may be internal or external to Novell. Novell makes all reasonable efforts to verify this information. However, the information provided in this document is for your information only. Novell makes no explicit or implied claims to the validity of this information.
Any trademarks referenced in this document are the property of their respective owners. Consult your product manuals for complete trademark information.