1 /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved 2 * 3 * The contents of this file is dual-licensed under 2 4 * alternative Open Source/Free licenses: LGPL 2.1 or later and 5 * Apache License 2.0. (starting with JNA version 4.0.0). 6 * 7 * You can freely decide which license you want to apply to 8 * the project. 9 * 10 * You may obtain a copy of the LGPL License at: 11 * 12 * http://www.gnu.org/licenses/licenses.html 13 * 14 * A copy is also included in the downloadable source code package 15 * containing JNA, in file "LGPL2.1". 16 * 17 * You may obtain a copy of the Apache License at: 18 * 19 * http://www.apache.org/licenses/ 20 * 21 * A copy is also included in the downloadable source code package 22 * containing JNA, in file "AL2.0". 23 */ 24 package com.sun.jna.platform.win32; 25 26 import com.sun.jna.Memory; 27 import com.sun.jna.Native; 28 import com.sun.jna.Pointer; 29 import com.sun.jna.Structure; 30 import com.sun.jna.Structure.FieldOrder; 31 import com.sun.jna.Union; 32 import com.sun.jna.platform.win32.WinBase.SYSTEMTIME; 33 import com.sun.jna.platform.win32.WinDef.DWORD; 34 import com.sun.jna.platform.win32.WinDef.DWORDByReference; 35 import com.sun.jna.platform.win32.WinDef.INT_PTR; 36 import com.sun.jna.platform.win32.WinDef.LPVOID; 37 import com.sun.jna.platform.win32.WinNT.HANDLE; 38 import com.sun.jna.platform.win32.WinNT.HANDLEByReference; 39 import com.sun.jna.ptr.IntByReference; 40 import com.sun.jna.ptr.PointerByReference; 41 import com.sun.jna.win32.StdCallLibrary; 42 import com.sun.jna.win32.W32APIOptions; 43 44 /** 45 * Ported from Winspool.h. Windows SDK 6.0a 46 * 47 * @author dblock[at]dblock.org 48 */ 49 public interface Winspool extends StdCallLibrary { 50 51 Winspool INSTANCE = Native.load("Winspool.drv", Winspool.class, W32APIOptions.DEFAULT_OPTIONS); 52 53 public static final int CCHDEVICENAME = 32; 54 55 public static final int PRINTER_STATUS_PAUSED = 0x00000001; 56 public static final int PRINTER_STATUS_ERROR = 0x00000002; 57 public static final int PRINTER_STATUS_PENDING_DELETION = 0x00000004; 58 public static final int PRINTER_STATUS_PAPER_JAM = 0x00000008; 59 public static final int PRINTER_STATUS_PAPER_OUT = 0x00000010; 60 public static final int PRINTER_STATUS_MANUAL_FEED = 0x00000020; 61 public static final int PRINTER_STATUS_PAPER_PROBLEM = 0x00000040; 62 public static final int PRINTER_STATUS_OFFLINE = 0x00000080; 63 public static final int PRINTER_STATUS_IO_ACTIVE = 0x00000100; 64 public static final int PRINTER_STATUS_BUSY = 0x00000200; 65 public static final int PRINTER_STATUS_PRINTING = 0x00000400; 66 public static final int PRINTER_STATUS_OUTPUT_BIN_FULL = 0x00000800; 67 public static final int PRINTER_STATUS_NOT_AVAILABLE = 0x00001000; 68 public static final int PRINTER_STATUS_WAITING = 0x00002000; 69 public static final int PRINTER_STATUS_PROCESSING = 0x00004000; 70 public static final int PRINTER_STATUS_INITIALIZING = 0x00008000; 71 public static final int PRINTER_STATUS_WARMING_UP = 0x00010000; 72 public static final int PRINTER_STATUS_TONER_LOW = 0x00020000; 73 public static final int PRINTER_STATUS_NO_TONER = 0x00040000; 74 public static final int PRINTER_STATUS_PAGE_PUNT = 0x00080000; 75 public static final int PRINTER_STATUS_USER_INTERVENTION = 0x00100000; 76 public static final int PRINTER_STATUS_OUT_OF_MEMORY = 0x00200000; 77 public static final int PRINTER_STATUS_DOOR_OPEN = 0x00400000; 78 public static final int PRINTER_STATUS_SERVER_UNKNOWN = 0x00800000; 79 public static final int PRINTER_STATUS_POWER_SAVE = 0x01000000; 80 81 public static final int PRINTER_ATTRIBUTE_QUEUED = 0x00000001; 82 public static final int PRINTER_ATTRIBUTE_DIRECT = 0x00000002; 83 public static final int PRINTER_ATTRIBUTE_DEFAULT = 0x00000004; 84 public static final int PRINTER_ATTRIBUTE_SHARED = 0x00000008; 85 public static final int PRINTER_ATTRIBUTE_NETWORK = 0x00000010; 86 public static final int PRINTER_ATTRIBUTE_HIDDEN = 0x00000020; 87 public static final int PRINTER_ATTRIBUTE_LOCAL = 0x00000040; 88 public static final int PRINTER_ATTRIBUTE_ENABLE_DEVQ = 0x00000080; 89 public static final int PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS = 0x00000100; 90 public static final int PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST = 0x00000200; 91 public static final int PRINTER_ATTRIBUTE_WORK_OFFLINE = 0x00000400; 92 public static final int PRINTER_ATTRIBUTE_ENABLE_BIDI = 0x00000800; 93 public static final int PRINTER_ATTRIBUTE_RAW_ONLY = 0x00001000; 94 public static final int PRINTER_ATTRIBUTE_PUBLISHED = 0x00002000; 95 public static final int PRINTER_ATTRIBUTE_FAX = 0x00004000; 96 public static final int PRINTER_ATTRIBUTE_TS = 0x00008000; 97 public static final int PRINTER_ATTRIBUTE_PUSHED_USER = 0x00020000; 98 public static final int PRINTER_ATTRIBUTE_PUSHED_MACHINE = 0x00040000; 99 public static final int PRINTER_ATTRIBUTE_MACHINE = 0x00080000; 100 public static final int PRINTER_ATTRIBUTE_FRIENDLY_NAME = 0x00100000; 101 public static final int PRINTER_ATTRIBUTE_TS_GENERIC_DRIVER = 0x00200000; 102 103 public static final int PRINTER_CHANGE_ADD_PRINTER = 0x00000001; 104 public static final int PRINTER_CHANGE_SET_PRINTER = 0x00000002; 105 public static final int PRINTER_CHANGE_DELETE_PRINTER = 0x00000004; 106 public static final int PRINTER_CHANGE_FAILED_CONNECTION_PRINTER = 0x00000008; 107 public static final int PRINTER_CHANGE_PRINTER = 0x000000FF; 108 public static final int PRINTER_CHANGE_ADD_JOB = 0x00000100; 109 public static final int PRINTER_CHANGE_SET_JOB = 0x00000200; 110 public static final int PRINTER_CHANGE_DELETE_JOB = 0x00000400; 111 public static final int PRINTER_CHANGE_WRITE_JOB = 0x00000800; 112 public static final int PRINTER_CHANGE_JOB = 0x0000FF00; 113 public static final int PRINTER_CHANGE_ADD_FORM = 0x00010000; 114 public static final int PRINTER_CHANGE_SET_FORM = 0x00020000; 115 public static final int PRINTER_CHANGE_DELETE_FORM = 0x00040000; 116 public static final int PRINTER_CHANGE_FORM = 0x00070000; 117 public static final int PRINTER_CHANGE_ADD_PORT = 0x00100000; 118 public static final int PRINTER_CHANGE_CONFIGURE_PORT = 0x00200000; 119 public static final int PRINTER_CHANGE_DELETE_PORT = 0x00400000; 120 public static final int PRINTER_CHANGE_PORT = 0x00700000; 121 public static final int PRINTER_CHANGE_ADD_PRINT_PROCESSOR = 0x01000000; 122 public static final int PRINTER_CHANGE_DELETE_PRINT_PROCESSOR = 0x04000000; 123 public static final int PRINTER_CHANGE_PRINT_PROCESSOR = 0x07000000; 124 public static final int PRINTER_CHANGE_SERVER = 0x08000000; 125 public static final int PRINTER_CHANGE_ADD_PRINTER_DRIVER = 0x10000000; 126 public static final int PRINTER_CHANGE_SET_PRINTER_DRIVER = 0x20000000; 127 public static final int PRINTER_CHANGE_DELETE_PRINTER_DRIVER = 0x40000000; 128 public static final int PRINTER_CHANGE_PRINTER_DRIVER = 0x70000000; 129 public static final int PRINTER_CHANGE_TIMEOUT = 0x80000000; 130 public static final int PRINTER_CHANGE_ALL_WIN7 = 0x7F77FFFF; 131 public static final int PRINTER_CHANGE_ALL = 0x7777FFFF; 132 133 public static final int PRINTER_ENUM_DEFAULT = 0x00000001; 134 public static final int PRINTER_ENUM_LOCAL = 0x00000002; 135 public static final int PRINTER_ENUM_CONNECTIONS = 0x00000004; 136 public static final int PRINTER_ENUM_FAVORITE = 0x00000004; 137 public static final int PRINTER_ENUM_NAME = 0x00000008; 138 public static final int PRINTER_ENUM_REMOTE = 0x00000010; 139 public static final int PRINTER_ENUM_SHARED = 0x00000020; 140 public static final int PRINTER_ENUM_NETWORK = 0x00000040; 141 142 public static final int PRINTER_ENUM_EXPAND = 0x00004000; 143 public static final int PRINTER_ENUM_CONTAINER = 0x00008000; 144 145 public static final int PRINTER_ENUM_ICONMASK = 0x00ff0000; 146 public static final int PRINTER_ENUM_ICON1 = 0x00010000; 147 public static final int PRINTER_ENUM_ICON2 = 0x00020000; 148 public static final int PRINTER_ENUM_ICON3 = 0x00040000; 149 public static final int PRINTER_ENUM_ICON4 = 0x00080000; 150 public static final int PRINTER_ENUM_ICON5 = 0x00100000; 151 public static final int PRINTER_ENUM_ICON6 = 0x00200000; 152 public static final int PRINTER_ENUM_ICON7 = 0x00400000; 153 public static final int PRINTER_ENUM_ICON8 = 0x00800000; 154 public static final int PRINTER_ENUM_HIDE = 0x01000000; 155 156 public static final int PRINTER_NOTIFY_OPTIONS_REFRESH = 0x01; 157 158 public static final int PRINTER_NOTIFY_INFO_DISCARDED = 0x01; 159 160 public static final int PRINTER_NOTIFY_TYPE = 0x00; 161 public static final int JOB_NOTIFY_TYPE = 0x01; 162 163 public static final short PRINTER_NOTIFY_FIELD_SERVER_NAME = 0x00; 164 public static final short PRINTER_NOTIFY_FIELD_PRINTER_NAME = 0x01; 165 public static final short PRINTER_NOTIFY_FIELD_SHARE_NAME = 0x02; 166 public static final short PRINTER_NOTIFY_FIELD_PORT_NAME = 0x03; 167 public static final short PRINTER_NOTIFY_FIELD_DRIVER_NAME = 0x04; 168 public static final short PRINTER_NOTIFY_FIELD_COMMENT = 0x05; 169 public static final short PRINTER_NOTIFY_FIELD_LOCATION = 0x06; 170 public static final short PRINTER_NOTIFY_FIELD_DEVMODE = 0x07; 171 public static final short PRINTER_NOTIFY_FIELD_SEPFILE = 0x08; 172 public static final short PRINTER_NOTIFY_FIELD_PRINT_PROCESSOR = 0x09; 173 public static final short PRINTER_NOTIFY_FIELD_PARAMETERS = 0x0A; 174 public static final short PRINTER_NOTIFY_FIELD_DATATYPE = 0x0B; 175 public static final short PRINTER_NOTIFY_FIELD_SECURITY_DESCRIPTOR = 0x0C; 176 public static final short PRINTER_NOTIFY_FIELD_ATTRIBUTES = 0x0D; 177 public static final short PRINTER_NOTIFY_FIELD_PRIORITY = 0x0E; 178 public static final short PRINTER_NOTIFY_FIELD_DEFAULT_PRIORITY = 0x0F; 179 public static final short PRINTER_NOTIFY_FIELD_START_TIME = 0x10; 180 public static final short PRINTER_NOTIFY_FIELD_UNTIL_TIME = 0x11; 181 public static final short PRINTER_NOTIFY_FIELD_STATUS = 0x12; 182 public static final short PRINTER_NOTIFY_FIELD_STATUS_STRING = 0x13; 183 public static final short PRINTER_NOTIFY_FIELD_CJOBS = 0x14; 184 public static final short PRINTER_NOTIFY_FIELD_AVERAGE_PPM = 0x15; 185 public static final short PRINTER_NOTIFY_FIELD_TOTAL_PAGES = 0x16; 186 public static final short PRINTER_NOTIFY_FIELD_PAGES_PRINTED = 0x17; 187 public static final short PRINTER_NOTIFY_FIELD_TOTAL_BYTES = 0x18; 188 public static final short PRINTER_NOTIFY_FIELD_BYTES_PRINTED = 0x19; 189 public static final short PRINTER_NOTIFY_FIELD_OBJECT_GUID = 0x1A; 190 public static final short PRINTER_NOTIFY_FIELD_FRIENDLY_NAME = 0x1B; 191 public static final short PRINTER_NOTIFY_FIELD_BRANCH_OFFICE_PRINTING = 0x1C; 192 193 public static final short JOB_NOTIFY_FIELD_PRINTER_NAME = 0x00; 194 public static final short JOB_NOTIFY_FIELD_MACHINE_NAME = 0x01; 195 public static final short JOB_NOTIFY_FIELD_PORT_NAME = 0x02; 196 public static final short JOB_NOTIFY_FIELD_USER_NAME = 0x03; 197 public static final short JOB_NOTIFY_FIELD_NOTIFY_NAME = 0x04; 198 public static final short JOB_NOTIFY_FIELD_DATATYPE = 0x05; 199 public static final short JOB_NOTIFY_FIELD_PRINT_PROCESSOR = 0x06; 200 public static final short JOB_NOTIFY_FIELD_PARAMETERS = 0x07; 201 public static final short JOB_NOTIFY_FIELD_DRIVER_NAME = 0x08; 202 public static final short JOB_NOTIFY_FIELD_DEVMODE = 0x09; 203 public static final short JOB_NOTIFY_FIELD_STATUS = 0x0A; 204 public static final short JOB_NOTIFY_FIELD_STATUS_STRING = 0x0B; 205 public static final short JOB_NOTIFY_FIELD_SECURITY_DESCRIPTOR = 0x0C; 206 public static final short JOB_NOTIFY_FIELD_DOCUMENT = 0x0D; 207 public static final short JOB_NOTIFY_FIELD_PRIORITY = 0x0E; 208 public static final short JOB_NOTIFY_FIELD_POSITION = 0x0F; 209 public static final short JOB_NOTIFY_FIELD_SUBMITTED = 0x10; 210 public static final short JOB_NOTIFY_FIELD_START_TIME = 0x11; 211 public static final short JOB_NOTIFY_FIELD_UNTIL_TIME = 0x12; 212 public static final short JOB_NOTIFY_FIELD_TIME = 0x13; 213 public static final short JOB_NOTIFY_FIELD_TOTAL_PAGES = 0x14; 214 public static final short JOB_NOTIFY_FIELD_PAGES_PRINTED = 0x15; 215 public static final short JOB_NOTIFY_FIELD_TOTAL_BYTES = 0x16; 216 public static final short JOB_NOTIFY_FIELD_BYTES_PRINTED = 0x17; 217 public static final short JOB_NOTIFY_FIELD_REMOTE_JOB_ID = 0x18; 218 219 public static final int PRINTER_NOTIFY_CATEGORY_ALL = 0x001000; 220 public static final int PRINTER_NOTIFY_CATEGORY_3D = 0x002000; 221 222 /** 223 * The EnumPrinters function enumerates available printers, print servers, 224 * domains, or print providers. 225 * 226 * @param Flags 227 * The types of print objects that the function should enumerate. 228 * @param Name 229 * If Level is 1, Flags contains PRINTER_ENUM_NAME, and Name is 230 * non-NULL, then Name is a pointer to a null-terminated string 231 * that specifies the name of the object to enumerate. This 232 * string can be the name of a server, a domain, or a print 233 * provider. If Level is 1, Flags contains PRINTER_ENUM_NAME, and 234 * Name is NULL, then the function enumerates the available print 235 * providers. If Level is 1, Flags contains PRINTER_ENUM_REMOTE, 236 * and Name is NULL, then the function enumerates the printers in 237 * the user's domain. If Level is 2 or 5,Name is a pointer to a 238 * null-terminated string that specifies the name of a server 239 * whose printers are to be enumerated. If this string is NULL, 240 * then the function enumerates the printers installed on the 241 * local computer. If Level is 4, Name should be NULL. The 242 * function always queries on the local computer. When Name is 243 * NULL, setting Flags to PRINTER_ENUM_LOCAL | 244 * PRINTER_ENUM_CONNECTIONS enumerates printers that are 245 * installed on the local machine. These printers include those 246 * that are physically attached to the local machine as well as 247 * remote printers to which it has a network connection. When 248 * Name is not NULL, setting Flags to PRINTER_ENUM_LOCAL | 249 * PRINTER_ENUM_NAME enumerates the local printers that are 250 * installed on the server Name. 251 * @param Level 252 * The type of data structures pointed to by pPrinterEnum. Valid 253 * values are 1, 2, 4, and 5, which correspond to the 254 * PRINTER_INFO_1, PRINTER_INFO_2 , PRINTER_INFO_4, and 255 * PRINTER_INFO_5 data structures. 256 * @param pPrinterEnum 257 * A pointer to a buffer that receives an array of 258 * PRINTER_INFO_1, PRINTER_INFO_2, PRINTER_INFO_4, or 259 * PRINTER_INFO_5 structures. Each structure contains data that 260 * describes an available print object. If Level is 1, the array 261 * contains PRINTER_INFO_1 structures. If Level is 2, the array 262 * contains PRINTER_INFO_2 structures. If Level is 4, the array 263 * contains PRINTER_INFO_4 structures. If Level is 5, the array 264 * contains PRINTER_INFO_5 structures. The buffer must be large 265 * enough to receive the array of data structures and any strings 266 * or other data to which the structure members point. If the 267 * buffer is too small, the pcbNeeded parameter returns the 268 * required buffer size. 269 * @param cbBuf 270 * The size, in bytes, of the buffer pointed to by pPrinterEnum. 271 * @param pcbNeeded 272 * A pointer to a value that receives the number of bytes copied 273 * if the function succeeds or the number of bytes required if 274 * cbBuf is too small. 275 * @param pcReturned 276 * A pointer to a value that receives the number of 277 * PRINTER_INFO_1, PRINTER_INFO_2 , PRINTER_INFO_4, or 278 * PRINTER_INFO_5 structures that the function returns in the 279 * array to which pPrinterEnum points. 280 * @return If the function succeeds, the return value is a nonzero value. If 281 * the function fails, the return value is zero. 282 * 283 * @see <a href= 284 * "https://msdn.microsoft.com/en-us/library/windows/desktop/dd162692(v=vs.85).aspx"> 285 * EnumPrinters function</a> 286 */ EnumPrinters(int Flags, String Name, int Level, Pointer pPrinterEnum, int cbBuf, IntByReference pcbNeeded, IntByReference pcReturned)287 boolean EnumPrinters(int Flags, String Name, int Level, 288 Pointer pPrinterEnum, int cbBuf, IntByReference pcbNeeded, 289 IntByReference pcReturned); 290 291 /** 292 * The GetPrinter function retrieves information about a specified printer. 293 * 294 * @param hPrinter A handle to the printer for which the function retrieves 295 * information. Use the OpenPrinter or AddPrinter function 296 * to retrieve a printer handle. 297 * @param Level The level or type of structure that the function stores 298 * into the buffer pointed to by pPrinter. This value can 299 * be 1, 2, 3, 4, 5, 6, 7, 8 or 9. 300 * @param pPrinter A pointer to a buffer that receives a structure 301 * containing information about the specified printer. The 302 * buffer must be large enough to receive the structure and 303 * any strings or other data to which the structure members 304 * point. If the buffer is too small, the pcbNeeded 305 * parameter returns the required buffer size. The type of 306 * structure is determined by the value of Level. 307 * @param cbBuf The size, in bytes, of the buffer pointed to by 308 * pPrinter. 309 * @param pcbNeeded A pointer to a variable that the function sets to the 310 * size, in bytes, of the printer information. If cbBuf is 311 * smaller than this value, GetPrinter fails, and the value 312 * represents the required buffer size. If cbBuf is equal 313 * to or greater than this value, GetPrinter succeeds, and 314 * the value represents the number of bytes stored in the 315 * buffer. 316 * 317 * @return If the function succeeds, the return value is a nonzero value. If 318 * the function fails, the return value is zero. 319 * 320 * @see <a href= 321 * "https://msdn.microsoft.com/en-us/library/windows/desktop/dd144911(v=vs.85).aspx"> 322 * GetPrinter function</a> 323 */ GetPrinter(HANDLE hPrinter, int Level, Pointer pPrinter, int cbBuf, IntByReference pcbNeeded)324 boolean GetPrinter(HANDLE hPrinter, int Level, Pointer pPrinter, int cbBuf, IntByReference pcbNeeded); 325 326 /** 327 * The PRINTER_INFO_1 structure specifies general printer information. 328 * 329 * @see <a href= 330 * "https://msdn.microsoft.com/en-us/library/windows/desktop/dd162844(v=vs.85).aspx"> 331 * PRINTER_INFO_1 structure</a> 332 */ 333 @FieldOrder({"Flags", "pDescription", "pName", "pComment"}) 334 public static class PRINTER_INFO_1 extends Structure { 335 336 /** 337 * Specifies information about the returned data. Following are the 338 * values for this member. 339 */ 340 public int Flags; 341 /** 342 * Pointer to a null-terminated string that describes the contents of 343 * the structure. 344 */ 345 public String pDescription; 346 /** 347 * Pointer to a null-terminated string that names the contents of the 348 * structure. 349 */ 350 public String pName; 351 /** 352 * Pointer to a null-terminated string that contains additional data 353 * describing the structure. 354 */ 355 public String pComment; 356 PRINTER_INFO_1()357 public PRINTER_INFO_1() { 358 super(); 359 } 360 PRINTER_INFO_1(int size)361 public PRINTER_INFO_1(int size) { 362 super(new Memory(size)); 363 } 364 } 365 366 /** 367 * The PRINTER_INFO_2 structure specifies detailed printer information. 368 * 369 * @author Ivan Ridao Freitas, Padrus 370 * @see <a href= 371 * "https://msdn.microsoft.com/en-us/library/windows/desktop/dd162845(v=vs.85).aspx"> 372 * PRINTER_INFO_2 structure</a> 373 */ 374 @FieldOrder({"pServerName", "pPrinterName", "pShareName", 375 "pPortName", "pDriverName", "pComment", "pLocation", "pDevMode", "pSepFile", "pPrintProcessor", 376 "pDatatype", "pParameters", "pSecurityDescriptor", "Attributes", "Priority", "DefaultPriority", 377 "StartTime", "UntilTime", "Status", "cJobs", "AveragePPM"}) 378 public static class PRINTER_INFO_2 extends Structure { 379 380 /** 381 * A pointer to a null-terminated string identifying the server that 382 * controls the printer. If this string is NULL, the printer is 383 * controlled locally. 384 */ 385 public String pServerName; 386 /** 387 * A pointer to a null-terminated string that specifies the name of the 388 * printer. 389 */ 390 public String pPrinterName; 391 /** 392 * A pointer to a null-terminated string that identifies the share point 393 * for the printer. (This string is used only if the 394 * PRINTER_ATTRIBUTE_SHARED constant was set for the Attributes member.) 395 */ 396 public String pShareName; 397 /** 398 * A pointer to a null-terminated string that identifies the port(s) 399 * used to transmit data to the printer. If a printer is connected to 400 * more than one port, the names of each port must be separated by 401 * commas (for example, "LPT1:,LPT2:,LPT3:"). 402 */ 403 public String pPortName; 404 /** 405 * A pointer to a null-terminated string that specifies the name of the 406 * printer driver. 407 */ 408 public String pDriverName; 409 /** 410 * A pointer to a null-terminated string that provides a brief 411 * description of the printer. 412 */ 413 public String pComment; 414 /** 415 * A pointer to a null-terminated string that specifies the physical 416 * location of the printer (for example, "Bldg. 38, Room 1164"). 417 */ 418 public String pLocation; 419 /** 420 * A pointer to a DEVMODE structure that defines default printer data 421 * such as the paper orientation and the resolution. 422 */ 423 public INT_PTR pDevMode; 424 /** 425 * A pointer to a null-terminated string that specifies the name of the 426 * file used to create the separator page. This page is used to separate 427 * print jobs sent to the printer. 428 */ 429 public String pSepFile; 430 /** 431 * A pointer to a null-terminated string that specifies the name of the 432 * print processor used by the printer. You can use the 433 * EnumPrintProcessors function to obtain a list of print processors 434 * installed on a server. 435 */ 436 public String pPrintProcessor; 437 /** 438 * A pointer to a null-terminated string that specifies the data type 439 * used to record the print job. You can use the 440 * EnumPrintProcessorDatatypes function to obtain a list of data types 441 * supported by a specific print processor. 442 */ 443 public String pDatatype; 444 /** 445 * A pointer to a null-terminated string that specifies the default 446 * print-processor parameters. 447 */ 448 public String pParameters; 449 /** 450 * A pointer to a SECURITY_DESCRIPTOR structure for the printer. This 451 * member may be NULL. 452 */ 453 public INT_PTR pSecurityDescriptor; 454 /** 455 * The printer attributes. This member can be any reasonable combination 456 * of the values PRINTER_ATTRIBUTE_XXX. 457 */ 458 public int Attributes; 459 /** 460 * A priority value that the spooler uses to route print jobs. 461 */ 462 public int Priority; 463 /** 464 * The default priority value assigned to each print job. 465 */ 466 public int DefaultPriority; 467 /** 468 * The earliest time at which the printer will print a job. This value 469 * is expressed as minutes elapsed since 12:00 AM GMT (Greenwich Mean 470 * Time). 471 */ 472 public int StartTime; 473 /** 474 * The latest time at which the printer will print a job. This value is 475 * expressed as minutes elapsed since 12:00 AM GMT (Greenwich Mean 476 * Time). 477 */ 478 public int UntilTime; 479 /** 480 * The printer status. This member can be any reasonable combination of 481 * the values PRINTER_STATUS_XXX. 482 */ 483 public int Status; 484 /** 485 * The number of print jobs that have been queued for the printer. 486 */ 487 public int cJobs; 488 /** 489 * The average number of pages per minute that have been printed on the 490 * printer. 491 */ 492 public int AveragePPM; 493 PRINTER_INFO_2()494 public PRINTER_INFO_2() { 495 super(); 496 } 497 PRINTER_INFO_2(int size)498 public PRINTER_INFO_2(int size) { 499 super(new Memory(size)); 500 } 501 502 /** 503 * Checks if the printer attributes have one of the values 504 * PRINTER_ATTRIBUTE_XXX. 505 */ hasAttribute(int value)506 public boolean hasAttribute(int value) { 507 return (Attributes & value) == value; 508 } 509 } 510 511 /** 512 * The PRINTER_INFO_4 structure specifies general printer information. 513 * <p> 514 * The structure can be used to retrieve minimal printer information on a 515 * call to EnumPrinters. Such a call is a fast and easy way to retrieve the 516 * names and attributes of all locally installed printers on a system and 517 * all remote printer connections that a user has established. 518 * 519 * @see <a href= 520 * "https://msdn.microsoft.com/en-us/library/windows/desktop/dd162847(v=vs.85).aspx"> 521 * PRINTER_INFO_4 structure</a> 522 */ 523 @FieldOrder({"pPrinterName", "pServerName", "Attributes"}) 524 public static class PRINTER_INFO_4 extends Structure { 525 526 /** 527 * Pointer to a null-terminated string that specifies the name of the 528 * printer (local or remote). 529 */ 530 public String pPrinterName; 531 /** 532 * Pointer to a null-terminated string that is the name of the server. 533 */ 534 public String pServerName; 535 /** 536 * Specifies information about the returned data. 537 */ 538 public DWORD Attributes; 539 PRINTER_INFO_4()540 public PRINTER_INFO_4() { 541 super(); 542 } 543 PRINTER_INFO_4(int size)544 public PRINTER_INFO_4(int size) { 545 super(new Memory(size)); 546 } 547 } 548 549 /** 550 * The PRINTER_DEFAULTS structure specifies the default data type, 551 * environment, initialization data, and access rights for a printer. 552 * 553 * @see <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd162839(v=vs.85).aspx">PRINTER_DEFAULTS structure</a> 554 */ 555 @FieldOrder({"pDatatype", "pDevMode", "DesiredAccess"}) 556 public class LPPRINTER_DEFAULTS extends Structure { 557 /** 558 * Pointer to a null-terminated string that specifies the default data 559 * type for a printer. 560 */ 561 public String pDatatype; 562 /** 563 * Pointer to a DEVMODE structure that identifies the default 564 * environment and initialization data for a printer. 565 */ 566 public Pointer pDevMode; 567 /** 568 * Specifies desired access rights for a printer. The OpenPrinter 569 * function uses this member to set access rights to the printer. These 570 * rights can affect the operation of the SetPrinter and DeletePrinter 571 * functions. 572 */ 573 public int DesiredAccess; 574 } 575 576 /** 577 * The OpenPrinter function retrieves a handle to the specified printer or 578 * print server or other types of handles in the print subsystem. 579 * 580 * @param pPrinterName 581 * [in] A pointer to a null-terminated string that specifies the 582 * name of the printer or print server, the printer object, the 583 * XcvMonitor, or the XcvPort. For a printer object use: 584 * PrinterName, Job xxxx. For an XcvMonitor, use: ServerName, 585 * XcvMonitor MonitorName. For an XcvPort, use: ServerName, 586 * XcvPort PortName. If NULL, it indicates the local printer 587 * server. 588 * @param phPrinter 589 * [out] A pointer to a variable that receives a handle (not 590 * thread safe) to the open printer or print server object. The 591 * phPrinter parameter can return an Xcv handle for use with the 592 * XcvData function. For more information about XcvData, see the 593 * DDK. 594 * @param pDefault 595 * [in] A pointer to a PRINTER_DEFAULTS structure. This value can 596 * be NULL. 597 * @return If the function succeeds, the return value is a nonzero value. If 598 * the function fails, the return value is zero. 599 * 600 * @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd162751(v=vs.85).aspx">OpenPrinter function</a> 601 */ OpenPrinter( String pPrinterName, HANDLEByReference phPrinter, LPPRINTER_DEFAULTS pDefault)602 boolean OpenPrinter( 603 // _In_ 604 String pPrinterName, 605 // _Out_ 606 HANDLEByReference phPrinter, 607 // _In_ 608 LPPRINTER_DEFAULTS pDefault); 609 610 /** 611 * The ClosePrinter function closes the specified printer object.<br> 612 * Note This is a blocking or synchronous function and might not return 613 * immediately.<br> 614 * How quickly this function returns depends on run-time factors such as 615 * network status, print server configuration, and printer driver 616 * implementation-factors that are difficult to predict when writing an 617 * application. Calling this function from a thread that manages interaction 618 * with the user interface could make the application appear to be 619 * unresponsive. 620 * <p> 621 * When the ClosePrinter function returns, the handle hPrinter is invalid, 622 * regardless of whether the function has succeeded or failed. 623 * 624 * @param hPrinter A handle to the printer object to be closed. This handle 625 * is returned by the OpenPrinter or AddPrinter function. 626 * 627 * @return If the function succeeds, the return value is a nonzero value. If 628 * the function fails, the return value is zero. 629 * 630 * @see <a href= 631 * "http://msdn.microsoft.com/en-us/library/windows/desktop/dd162751(v=vs.85).aspx"> 632 * ClosePrinter function</a> 633 */ ClosePrinter(HANDLE hPrinter)634 boolean ClosePrinter(HANDLE hPrinter); 635 636 /** 637 * The PRINTER_NOTIFY_OPTIONS structure specifies options for a change 638 * notification object that monitors a printer or print server. 639 * 640 * @see 641 * <a href="https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-notify-options"> 642 * PRINTER_NOTIFY_OPTIONS structure 643 * </a> 644 */ 645 @Structure.FieldOrder({ "Version", "Flags", "Count", "pTypes" }) 646 public class PRINTER_NOTIFY_OPTIONS extends Structure { 647 648 /** 649 * The version of this structure. Set this member to 2. 650 */ 651 public int Version = 2; 652 653 /** 654 * A bit flag. If you set the PRINTER_NOTIFY_OPTIONS_REFRESH flag in a 655 * call to the FindNextPrinterChangeNotification function, the function 656 * provides current data for all monitored printer information fields. 657 * The FindFirstPrinterChangeNotification function ignores the Flags 658 * member. 659 */ 660 public int Flags; 661 662 /** 663 * The number of elements in the pTypes array. 664 */ 665 public int Count; 666 667 /** 668 * A pointer to an array of PRINTER_NOTIFY_OPTIONS_TYPE structures. Use 669 * one element of this array to specify the printer information fields 670 * to monitor, and one element to specify the job information fields to 671 * monitor. You can monitor either printer information, job 672 * information, or both. 673 */ 674 public PRINTER_NOTIFY_OPTIONS_TYPE.ByReference pTypes; 675 676 } 677 678 /** 679 * The PRINTER_NOTIFY_OPTIONS_TYPE structure specifies the set of printer 680 * or job information fields to be monitored by a printer change 681 * notification object. 682 * 683 * @see 684 * <a href="https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-notify-options-type"> 685 * PRINTER_NOTIFY_OPTIONS_TYPE structure 686 * </a> 687 */ 688 @Structure.FieldOrder({ "Type", "Reserved0", "Reserved1", "Reserved2", 689 "Count", "pFields" }) 690 public class PRINTER_NOTIFY_OPTIONS_TYPE extends Structure { 691 692 public static class ByReference extends PRINTER_NOTIFY_OPTIONS_TYPE 693 implements Structure.ByReference { 694 } 695 696 /** 697 * The type to be watched. 698 */ 699 public short Type; 700 701 /** 702 * Reserved. 703 */ 704 public short Reserved0; 705 706 /** 707 * Reserved. 708 */ 709 public int Reserved1; 710 711 /** 712 * Reserved. 713 */ 714 public int Reserved2; 715 716 /** 717 * The number of elements in the pFields array. 718 */ 719 public int Count; 720 721 /** 722 * A pointer to an array of values. Each element of the array specifies 723 * a job or printer information field of interest. 724 */ 725 public Pointer pFields; 726 setFields(short[] fields)727 public void setFields(short[] fields) { 728 final long shortSizeInBytes = 2L; 729 Memory fieldsMemory = new Memory(fields.length * shortSizeInBytes); 730 fieldsMemory.write(0, fields, 0, fields.length); 731 pFields = fieldsMemory; 732 Count = fields.length; 733 } 734 getFields()735 public short[] getFields() { 736 return pFields.getShortArray(0, Count); 737 } 738 } 739 740 /** 741 * The PRINTER_NOTIFY_INFO structure contains printer information returned 742 * by the FindNextPrinterChangeNotification function. The function returns 743 * this information after a wait operation on a printer change notification 744 * object has been satisfied. 745 * 746 * @see 747 * <a href="https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-notify-info"> 748 * PRINTER_NOTIFY_INFO structure 749 * </a> 750 */ 751 @Structure.FieldOrder({ "Version", "Flags", "Count", "aData" }) 752 public class PRINTER_NOTIFY_INFO extends Structure { 753 754 /** 755 * The version of this structure. Set this member to 2. 756 */ 757 public int Version; 758 759 /** 760 * A bit flag that indicates the state of the notification structure. If 761 * the PRINTER_NOTIFY_INFO_DISCARDED bit is set, it indicates that some 762 * notifications had to be discarded. 763 */ 764 public int Flags; 765 766 /** 767 * The number of PRINTER_NOTIFY_INFO_DATA elements in the aData array. 768 */ 769 public int Count; 770 771 /** 772 * An array of PRINTER_NOTIFY_INFO_DATA structures. Each element of the 773 * array identifies a single job or printer information field, and 774 * provides the current data for that field. 775 */ 776 public PRINTER_NOTIFY_INFO_DATA[] aData = 777 new PRINTER_NOTIFY_INFO_DATA[1]; 778 779 @Override read()780 public void read() { 781 int count = (Integer) readField("Count"); 782 aData = new PRINTER_NOTIFY_INFO_DATA[count]; 783 if (count == 0) { 784 Count = count; 785 Version = (Integer) readField("Version"); 786 Flags = (Integer) readField("Flags"); 787 } else { 788 super.read(); 789 } 790 } 791 792 } 793 794 /** 795 * A struct containing non-numeric notification data - conditional content 796 * of a {@link NOTIFY_DATA} union. 797 */ 798 @Structure.FieldOrder({ "cbBuf", "pBuf" }) 799 public class NOTIFY_DATA_DATA extends Structure { 800 801 /** 802 * Indicates the size, in bytes, of the buffer pointed to by pBuf. 803 */ 804 public int cbBuf; 805 806 /** 807 * Pointer to a buffer that contains the field's current data. 808 */ 809 public Pointer pBuf; 810 811 } 812 813 /** 814 * A union of data information based on the Type and Field members of 815 * {@link PRINTER_NOTIFY_INFO_DATA} 816 */ 817 public class NOTIFY_DATA extends Union { 818 819 /** 820 * Set if the notification data is numeric. 821 * 822 * An array of two DWORD values. For information fields that use only a 823 * single DWORD, the data is in adwData [0]. 824 */ 825 public int[] adwData = new int[2]; 826 827 /** 828 * Set if the notification data is non-numeric. 829 */ 830 public NOTIFY_DATA_DATA Data; 831 832 } 833 834 /** 835 * The PRINTER_NOTIFY_INFO_DATA structure identifies a job or printer 836 * information field and provides the current data for that field. 837 * 838 * @see 839 * <a href="https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-notify-info-data"> 840 * PRINTER_NOTIFY_INFO_DATA structure 841 * </a> 842 */ 843 @Structure.FieldOrder({ "Type", "Field", "Reserved", "Id", "NotifyData" }) 844 public class PRINTER_NOTIFY_INFO_DATA extends Structure { 845 846 /** 847 * Indicates the type of information provided. 848 */ 849 public short Type; 850 851 /** 852 * Indicates the field that changed. 853 */ 854 public short Field; 855 856 /** 857 * Reserved. 858 */ 859 public int Reserved; 860 861 /** 862 * Indicates the job identifier if the Type member specifies 863 * JOB_NOTIFY_TYPE. If the Type member specifies PRINTER_NOTIFY_TYPE, 864 * this member is undefined. 865 */ 866 public int Id; 867 868 /** 869 * A union of data information based on the Type and Field members. 870 */ 871 public NOTIFY_DATA NotifyData; 872 873 @Override read()874 public void read() { 875 super.read(); 876 877 boolean numericData; 878 if (Type == PRINTER_NOTIFY_TYPE) { 879 switch (Field) { 880 case PRINTER_NOTIFY_FIELD_ATTRIBUTES: 881 // Fall-through 882 case PRINTER_NOTIFY_FIELD_PRIORITY: 883 // Fall-through 884 case PRINTER_NOTIFY_FIELD_DEFAULT_PRIORITY: 885 // Fall-through 886 case PRINTER_NOTIFY_FIELD_START_TIME: 887 // Fall-through 888 case PRINTER_NOTIFY_FIELD_UNTIL_TIME: 889 // Fall-through 890 case PRINTER_NOTIFY_FIELD_STATUS: 891 // Fall-through 892 case PRINTER_NOTIFY_FIELD_CJOBS: 893 // Fall-through 894 case PRINTER_NOTIFY_FIELD_AVERAGE_PPM: 895 numericData = true; 896 default: 897 numericData = false; 898 } 899 } else { 900 switch (Field) { 901 case JOB_NOTIFY_FIELD_STATUS: 902 // Fall-through 903 case JOB_NOTIFY_FIELD_PRIORITY: 904 // Fall-through 905 case JOB_NOTIFY_FIELD_POSITION: 906 // Fall-through 907 case JOB_NOTIFY_FIELD_START_TIME: 908 // Fall-through 909 case JOB_NOTIFY_FIELD_UNTIL_TIME: 910 // Fall-through 911 case JOB_NOTIFY_FIELD_TIME: 912 // Fall-through 913 case JOB_NOTIFY_FIELD_TOTAL_PAGES: 914 // Fall-through 915 case JOB_NOTIFY_FIELD_PAGES_PRINTED: 916 // Fall-through 917 case JOB_NOTIFY_FIELD_TOTAL_BYTES: 918 // Fall-through 919 case JOB_NOTIFY_FIELD_BYTES_PRINTED: 920 numericData = true; 921 default: 922 numericData = false; 923 } 924 } 925 if (numericData) { 926 NotifyData.setType(int[].class); 927 } else { 928 NotifyData.setType(NOTIFY_DATA_DATA.class); 929 } 930 NotifyData.read(); 931 } 932 } 933 934 @Deprecated FindFirstPrinterChangeNotification( HANDLE hPrinter, int fdwFilter, int fdwOptions, LPVOID pPrinterNotifyOptions)935 HANDLE FindFirstPrinterChangeNotification( 936 // _In_ 937 HANDLE hPrinter, 938 int fdwFilter, 939 int fdwOptions, 940 // _In_opt_ 941 LPVOID pPrinterNotifyOptions); 942 943 /** 944 * The FindFirstPrinterChangeNotification function creates a change 945 * notification object and returns a handle to the object. You can then use 946 * this handle in a call to one of the wait functions to monitor changes to 947 * the printer or print server. The FindFirstPrinterChangeNotification call 948 * specifies the type of changes to be monitored. You can specify a set of 949 * conditions to monitor for changes, a set of printer information fields to 950 * monitor, or both. A wait operation on the change notification handle 951 * succeeds when one of the specified changes occurs in the specified 952 * printer or print server. You then call the 953 * FindNextPrinterChangeNotification function to retrieve information about 954 * the change, and to reset the change notification object for use in the 955 * next wait operation. 956 * 957 * @param hPrinter 958 * [in] A handle to the printer or print server that you want to 959 * monitor. Use the OpenPrinter or AddPrinter function to 960 * retrieve a printer handle. 961 * @param fdwFilter 962 * The conditions that will cause the change notification object 963 * to enter a signaled state. A change notification occurs when 964 * one or more of the specified conditions are met. The fdwFilter 965 * parameter can be zero if pPrinterNotifyOptions is non-NULL. 966 * 967 * @param fdwOptions 968 * Reserved; must be zero. 969 * @param pPrinterNotifyOptions 970 * [in, optional] A pointer to a PRINTER_NOTIFY_OPTIONS 971 * structure. The pTypes member of this structure is an array of 972 * one or more PRINTER_NOTIFY_OPTIONS_TYPE structures, each of which 973 * specifies a printer information field to monitor. A change 974 * notification occurs when one or more of the specified fields 975 * changes. When a change occurs, the 976 * FindNextPrinterChangeNotification function can retrieve the 977 * new printer information. This parameter can be NULL if 978 * fdwFilter is nonzero. For a list of fields that can be 979 * monitored, see PRINTER_NOTIFY_OPTIONS_TYPE. 980 * 981 * @return If the function succeeds, the return value is a handle to a 982 * change notification object associated with the specified printer 983 * or print server. If the function fails, the return value is 984 * INVALID_HANDLE_VALUE. 985 * 986 * @see <a href= 987 * "http://msdn.microsoft.com/en-us/library/windows/desktop/dd162722(v=vs.85).aspx"> 988 * FindFirstPrinterChangeNotification function</a> 989 */ FindFirstPrinterChangeNotification( HANDLE hPrinter, int fdwFilter, int fdwOptions, PRINTER_NOTIFY_OPTIONS pPrinterNotifyOptions)990 HANDLE FindFirstPrinterChangeNotification( 991 // _In_ 992 HANDLE hPrinter, 993 int fdwFilter, 994 int fdwOptions, 995 // _In_opt_ 996 PRINTER_NOTIFY_OPTIONS pPrinterNotifyOptions); 997 998 @Deprecated FindNextPrinterChangeNotification( HANDLE hChange, DWORDByReference pdwChange, LPVOID pPrinterNotifyOptions, LPVOID ppPrinterNotifyInfo)999 boolean FindNextPrinterChangeNotification( 1000 // _In_ 1001 HANDLE hChange, 1002 // _Out_opt_ 1003 DWORDByReference pdwChange, 1004 // _In_opt_ 1005 LPVOID pPrinterNotifyOptions, 1006 // _Out_opt_ 1007 LPVOID ppPrinterNotifyInfo); 1008 1009 /** 1010 * The FindNextPrinterChangeNotification function retrieves information 1011 * about the most recent change notification for a change notification 1012 * object associated with a printer or print server. Call this function when 1013 * a wait operation on the change notification object is satisfied. The 1014 * function also resets the change notification object to the not-signaled 1015 * state. You can then use the object in another wait operation to continue 1016 * monitoring the printer or print server. The operating system will set the 1017 * object to the signaled state the next time one of a specified set of 1018 * changes occurs to the printer or print server. The 1019 * FindFirstPrinterChangeNotification function creates the change 1020 * notification object and specifies the set of changes to be monitored. 1021 * 1022 * @param hChange 1023 * [in] A handle to a change notification object associated with 1024 * a printer or print server. You obtain such a handle by calling 1025 * the FindFirstPrinterChangeNotification function. The operating 1026 * system sets this change notification object to the signaled 1027 * state when it detects one of the changes specified in the 1028 * object's change notification filter. 1029 * @param pdwChange 1030 * [out, optional] A pointer to a variable whose bits are set to 1031 * indicate the changes that occurred to cause the most recent 1032 * notification. The bit flags that might be set correspond to 1033 * those specified in the fdwFilter parameter of the 1034 * FindFirstPrinterChangeNotification call. The system sets one 1035 * or more of the following bit flags. 1036 * 1037 * @param pPrinterNotifyOptions 1038 * [in, optional] A pointer to a PRINTER_NOTIFY_OPTIONS 1039 * structure. Set the Flags member of this structure to 1040 * PRINTER_NOTIFY_OPTIONS_REFRESH, to cause the function to 1041 * return the current data for all monitored printer information 1042 * fields. The function ignores all other members of the 1043 * structure. This parameter can be NULL. 1044 * 1045 * @param ppPrinterNotifyInfo 1046 * [out, optional] A pointer to a pointer variable that receives 1047 * a pointer to a system-allocated, read-only buffer. Call the 1048 * FreePrinterNotifyInfo function to free the buffer when you are 1049 * finished with it. This parameter can be NULL if no information 1050 * is required. The buffer contains a PRINTER_NOTIFY_INFO 1051 * structure, which contains an array of PRINTER_NOTIFY_INFO_DATA 1052 * structures. Each element of the array contains information 1053 * about one of the fields specified in the pPrinterNotifyOptions 1054 * parameter of the FindFirstPrinterChangeNotification call. 1055 * Typically, the function provides data only for the fields that 1056 * changed to cause the most recent notification. However, if the 1057 * structure pointed to by the pPrinterNotifyOptions parameter 1058 * specifies PRINTER_NOTIFY_OPTIONS_REFRESH, the function 1059 * provides data for all monitored fields. If the 1060 * PRINTER_NOTIFY_INFO_DISCARDED bit is set in the Flags member 1061 * of the PRINTER_NOTIFY_INFO structure, an overflow or error 1062 * occurred, and notifications may have been lost. In this case, 1063 * no additional notifications will be sent until you make a 1064 * second FindNextPrinterChangeNotification call that specifies 1065 * PRINTER_NOTIFY_OPTIONS_REFRESH. 1066 * 1067 * @return If the function succeeds, the return value is a nonzero value. If 1068 * the function fails, the return value is zero. 1069 * 1070 * @see <a href= 1071 * "http://msdn.microsoft.com/en-us/library/windows/desktop/dd162721(v=vs.85).aspx"> 1072 * FindClosePrinterChangeNotification function</a> 1073 */ FindNextPrinterChangeNotification( HANDLE hChange, DWORDByReference pdwChange, PRINTER_NOTIFY_OPTIONS pPrinterNotifyOptions, PointerByReference ppPrinterNotifyInfo)1074 boolean FindNextPrinterChangeNotification( 1075 // _In_ 1076 HANDLE hChange, 1077 // _Out_opt_ 1078 DWORDByReference pdwChange, 1079 // _In_opt_ 1080 PRINTER_NOTIFY_OPTIONS pPrinterNotifyOptions, 1081 // _Out_opt_ 1082 PointerByReference ppPrinterNotifyInfo); 1083 1084 /** 1085 * The FindClosePrinterChangeNotification function closes a change 1086 * notification object created by calling the 1087 * FindFirstPrinterChangeNotification function. The printer or print server 1088 * associated with the change notification object will no longer be 1089 * monitored by that object. 1090 * 1091 * @param hChange 1092 * [in] A handle to the change notification object to be closed. 1093 * This is a handle created by calling the 1094 * FindFirstPrinterChangeNotification function. 1095 * 1096 * @return If the function succeeds, the return value is a nonzero value. If 1097 * the function fails, the return value is zero. 1098 * 1099 * @see <a href= 1100 * "http://msdn.microsoft.com/en-us/library/windows/desktop/dd162721(v=vs.85).aspx"> 1101 * FindClosePrinterChangeNotification function</a> 1102 */ FindClosePrinterChangeNotification( HANDLE hChange)1103 boolean FindClosePrinterChangeNotification( 1104 // _In_ 1105 HANDLE hChange); 1106 1107 /** 1108 * The FreePrinterNotifyInfo function frees a system-allocated buffer 1109 * created by the FindNextPrinterChangeNotification function. 1110 * 1111 * @param pPrinterNotifyInfo 1112 * [in] Pointer to a PRINTER_NOTIFY_INFO buffer returned from a 1113 * call to the FindNextPrinterChangeNotification function. 1114 * FreePrinterNotifyInfo deallocates this buffer. 1115 * 1116 * @return If the function succeeds, the return value is a nonzero value. If 1117 * the function fails, the return value is zero. 1118 * 1119 * @see 1120 * <a href="https://docs.microsoft.com/en-us/windows/win32/printdocs/freeprinternotifyinfo"> 1121 * FreePrinterNotifyInfo function 1122 * </a> 1123 */ FreePrinterNotifyInfo( Pointer pPrinterNotifyInfo)1124 boolean FreePrinterNotifyInfo( 1125 // _In_ 1126 Pointer pPrinterNotifyInfo); 1127 1128 /** 1129 * The EnumJobs function retrieves information about a specified set of 1130 * print jobs for a specified printer. 1131 * 1132 * @param hPrinter A handle to the printer object whose print jobs the 1133 * function enumerates. Use the OpenPrinter or AddPrinter 1134 * function to retrieve a printer handle. 1135 * @param FirstJob The zero-based position within the print queue of the 1136 * first print job to enumerate. For example, a value of 0 1137 * specifies that enumeration should begin at the first 1138 * print job in the print queue; a value of 9 specifies 1139 * that enumeration should begin at the tenth print job in 1140 * the print queue. 1141 * @param NoJobs The total number of print jobs to enumerate. 1142 * @param Level The type of information returned in the pJob buffer. 1143 * @param pJob A pointer to a buffer that receives an array of 1144 * JOB_INFO_1, JOB_INFO_2, or JOB_INFO_3 structures. The 1145 * buffer must be large enough to receive the array of 1146 * structures and any strings or other data to which the 1147 * structure members point. 1148 * @param cbBuf The size, in bytes, of the pJob buffer. 1149 * @param pcbNeeded A pointer to a variable that receives the number of 1150 * bytes copied if the function succeeds. If the function 1151 * fails, the variable receives the number of bytes 1152 * required. 1153 * @param pcReturned A pointer to a variable that receives the number of 1154 * JOB_INFO_1, JOB_INFO_2, or JOB_INFO_3 structures 1155 * returned in the pJob buffer. 1156 * 1157 * @return If the function succeeds, the return value is a nonzero value. If 1158 * the function fails, the return value is zero. 1159 * 1160 * @see <a href= 1161 * "https://msdn.microsoft.com/en-us/library/windows/desktop/dd162625(v=vs.85).aspx"> 1162 * EnumJobs function</a> 1163 */ EnumJobs( HANDLE hPrinter, int FirstJob, int NoJobs, int Level, Pointer pJob, int cbBuf, IntByReference pcbNeeded, IntByReference pcReturned)1164 boolean EnumJobs( 1165 // _In_ 1166 HANDLE hPrinter, 1167 // _In_ 1168 int FirstJob, 1169 // _In_ 1170 int NoJobs, 1171 // _In_ 1172 int Level, 1173 // _Out_ 1174 Pointer pJob, 1175 // _In_ 1176 int cbBuf, 1177 // _Out_ 1178 IntByReference pcbNeeded, 1179 // _Out_ 1180 IntByReference pcReturned); 1181 1182 /** 1183 * The JOB_INFO_1 structure specifies print-job information such as the 1184 * job-identifier value, the name of the printer for which the job is 1185 * spooled, the name of the machine that created the print job, the name of 1186 * the user that owns the print job, and so on. 1187 * 1188 * @see <a href= 1189 * "https://msdn.microsoft.com/en-us/library/windows/desktop/dd145019(v=vs.85).aspx"> 1190 * JOB_INFO_1 structure</a> 1191 */ 1192 @FieldOrder({"JobId", "pPrinterName", "pMachineName", "pUserName", 1193 "pDocument", "pDatatype", "pStatus", "Status", "Priority", 1194 "Position", "TotalPages", "PagesPrinted", "Submitted"}) 1195 public static class JOB_INFO_1 extends Structure { 1196 1197 /** 1198 * A job identifier. 1199 */ 1200 public int JobId; 1201 /** 1202 * A pointer to a null-terminated string that specifies the name of the 1203 * printer for which the job is spooled. 1204 */ 1205 public String pPrinterName; 1206 /** 1207 * A pointer to a null-terminated string that specifies the name of the 1208 * machine that created the print job. 1209 */ 1210 public String pMachineName; 1211 /** 1212 * A pointer to a null-terminated string that specifies the name of the 1213 * user that owns the print job. 1214 */ 1215 public String pUserName; 1216 /** 1217 * A pointer to a null-terminated string that specifies the name of the 1218 * print job (for example, "MS-WORD: Review.doc"). 1219 */ 1220 public String pDocument; 1221 /** 1222 * A pointer to a null-terminated string that specifies the type of data 1223 * used to record the print job. 1224 */ 1225 public String pDatatype; 1226 /** 1227 * A pointer to a null-terminated string that specifies the status of 1228 * the print job. This member should be checked prior to Status and, if 1229 * pStatus is NULL, the status is defined by the contents of the Status 1230 * member. 1231 */ 1232 public String pStatus; 1233 /** 1234 * The job status. The value of this member can be zero or a combination 1235 * of one or more of the following values. A value of zero indicates 1236 * that the print queue was paused after the document finished spooling. 1237 */ 1238 public int Status; 1239 /** 1240 * The job priority. This member can be one of the following values or 1241 * in the range between 1 through 99 (MIN_PRIORITY through 1242 * MAX_PRIORITY). 1243 */ 1244 public int Priority; 1245 /** 1246 * The job's position in the print queue. 1247 */ 1248 public int Position; 1249 /** 1250 * The total number of pages that the document contains. This value may 1251 * be zero if the print job does not contain page delimiting 1252 * information. 1253 */ 1254 public int TotalPages; 1255 /** 1256 * The number of pages that have printed. This value may be zero if the 1257 * print job does not contain page delimiting information. 1258 */ 1259 public int PagesPrinted; 1260 /** 1261 * A SYSTEMTIME structure that specifies the time that this document was 1262 * spooled. 1263 * <p> 1264 * This time value is in Universal Time Coordinate (UTC) format. You 1265 * should convert it to a local time value before displaying it. You can 1266 * use the FileTimeToLocalFileTime function to perform the conversion. 1267 */ 1268 public SYSTEMTIME Submitted; 1269 JOB_INFO_1()1270 public JOB_INFO_1() { 1271 super(); 1272 } 1273 JOB_INFO_1(int size)1274 public JOB_INFO_1(int size) { 1275 super(new Memory(size)); 1276 } 1277 } 1278 } 1279