Bonjour à tous

Je cherche à modifier la configuration des bac pour une imprimante.

Environnement windows xp et windows 2003

Actuellement j'arrivé à afficher la fenêtre des bac mais les options sont grisées.

Comment fait-on pour avoir les droits de modification ?

Merci pour votre aide.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
 
Module Modification_imprimante 
Public Declare Function PrinterProperties Lib "winspool.drv" (ByVal hwnd As Integer, ByVal hPrinter As Integer) As Integer 
Public Declare Function openprinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, ByRef phPrinter As Integer, ByRef pDefault As PRINTER_DEFAULTS) As Integer 
Public Declare Function SetPrinter Lib "winspool.drv" Alias "SetPrinterA" (ByVal pPrinterName As Long, ByVal Level As Long, ByVal phPrinter As Integer, ByVal Command As Long) As Long 
Public Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Integer) As Integer 
 
 
'Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long 
'Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long 
'Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal hpvDest As String, ByVal hpvSource As String, ByVal cbCopy As Long) 
'Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long 
 
 
'Constants for DEVMODE structure 
Private Const CCHDEVICENAME = 32 
Private Const CCHFORMNAME = 32 
 
Public Const PRINTER_ACCESS_ADMINISTER As Int32 = &H4 
Public Const STANDARD_RIGHTS_REQUIRED As Int32 = &HF0000 
Public Const PRINTER_ACCESS_USE As Int32 = &H8 
Public Const PRINTER_ALL_ACCESS As Int32 = STANDARD_RIGHTS_REQUIRED Or PRINTER_ACCESS_USE Or PRINTER_ACCESS_ADMINISTER 
 
 
Public Structure DEVMODE 
<VBFixedString(CCHDEVICENAME), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=CCHDEVICENAME)> Public dmDeviceName() As Char 
Dim dmSpecVersion As Short 
Dim dmDriverVersion As Short 
Dim dmSize As Short 
Dim dmDriverExtra As Short 
Dim dmFields As Integer 
Dim dmOrientation As Short 
Dim dmPaperSize As Short 
Dim dmPaperLength As Short 
Dim dmPaperWidth As Short 
Dim dmScale As Short 
Dim dmCopies As Short 
Dim dmDefaultSource As Short 
Dim dmPrintQuality As Short 
Dim dmColor As Short 
Dim dmDuplex As Short 
Dim dmYResolution As Short 
Dim dmTTOption As Short 
Dim dmCollate As Short 
<VBFixedString(CCHFORMNAME), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=CCHFORMNAME)> Public dmFormName() As Char 
Dim dmUnusedPadding As Short 
Dim dmBitsPerPel As Integer 
Dim dmPelsWidth As Integer 
Dim dmPelsHeight As Integer 
Dim dmDisplayFlags As Integer 
Dim dmDisplayFrequency As Integer 
End Structure 
 
 
Public Structure PRINTER_DEFAULTS 
'Dim pDatatype As String 
'Dim pDevMode As DEVMODE 
'Dim DesiredAccess As Integer 
'Modification 
Dim pDatatype As Long 
Dim pDevMode As Long 
Dim DesiredAccess As Long 
End Structure 
 
 
 
Public Sub configurer() 
Dim Printer As New Printer 
Dim lgRep As Integer 
Dim lgHnd As Integer 
Dim tyPrinter As PRINTER_DEFAULTS 
 
On Error GoTo ErrorHandler 
 
Const PRINTER_ALL_ACCESS = &HF000C 
tyPrinter.pDatatype = 0 
tyPrinter.DesiredAccess = PRINTER_ALL_ACCESS 
tyPrinter.pDevMode = 0 
 
lgRep = openprinter(frmPrincipal.Imp, lgHnd, tyPrinter) 
 
If (lgRep <> 0) Then 
lgRep = PrinterProperties(frmPrincipal.Handle.ToInt32, lgHnd) 
 
ClosePrinter(lgHnd) 
End If 
 
ErrorHandler: 
If lgRep <> 0 Then ClosePrinter(lgHnd) 
 
End Sub 
End Module