home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 14 / IOPROG_14.ISO / soft / sdkjava / sdkjava.exe / SDKJava.cab / Src / Win32Api / Spoolss.java < prev    next >
Encoding:
Java Source  |  1998-03-05  |  12.3 KB  |  246 lines

  1. // Copyright (C) 1997 Microsoft Corporation  All Rights Reserved
  2.  
  3. // These classes provide direct, low-overhead access to commonly used
  4. // Windows api. These classes use the new J/Direct feature.
  5. //
  6. // Information on how to use J/Direct to write your own declarations
  7. // can be found in the Microsoft SDK for Java 2.0.
  8.  
  9. package com.ms.win32;
  10.  
  11. /** @security(checkClassLinking=on) */
  12. public class Spoolss {
  13.         /** @dll.import("WINSPOOL.DRV",auto) */
  14.         public native static boolean AbortPrinter (int hPrinter);
  15.  
  16.         /** @dll.import("WINSPOOL.DRV",auto) */
  17.         public native static boolean AddForm (int hPrinter, int Level, FORM_INFO_1 pForm);
  18.  
  19.         /** @dll.import("WINSPOOL.DRV",auto) */
  20.         public native static boolean AddJob (int hPrinter, int Level, Object pData, int cbBuf, int[] pcbNeeded);
  21.  
  22.         /** @dll.import("WINSPOOL.DRV", auto) */
  23.         public native static boolean AddMonitor (String pName, int Level, Object pMonitors);
  24.  
  25.         /** @dll.import("WINSPOOL.DRV", auto) */
  26.         public native static boolean AddPort (String pName, int hWnd, String pMonitorName);
  27.  
  28.         /** @dll.import("WINSPOOL.DRV", auto) */
  29.         public native static boolean AddPrintProcessor (String pName, String pEnvironment, String pPathName, String pPrintProcessorName);
  30.  
  31.         /** @dll.import("WINSPOOL.DRV", auto) */
  32.         public native static boolean AddPrintProvidor (String pName, int level, Object pProvidorInfo);
  33.  
  34.         /** @dll.import("WINSPOOL.DRV", auto) */
  35.         public native static boolean AddPrinterConnection (String pName);
  36.  
  37.         /** @dll.import("WINSPOOL.DRV", auto) */
  38.         public native static boolean AddPrinterDriver (String pName, int Level, Object pDriverInfo);
  39.  
  40.         /** @dll.import("WINSPOOL.DRV", auto) */
  41.         public native static int AddPrinter (String pName, int Level, Object pPrinter);
  42.  
  43.         /** @dll.import("WINSPOOL.DRV",auto) */
  44.         public native static boolean ClosePrinter (int hPrinter);
  45.  
  46.         /** @dll.import("WINSPOOL.DRV", auto) */
  47.         public native static boolean ConfigurePort (String pName, int hWnd, String pPortName);
  48.  
  49.         /** @dll.import("WINSPOOL.DRV", auto) */
  50.         public native static boolean DeleteForm (int hPrinter, String pFormName);
  51.  
  52.         /** @dll.import("WINSPOOL.DRV", auto) */
  53.         public native static boolean DeleteMonitor (String pName, String pEnvironment, String pMonitorName);
  54.  
  55.         /** @dll.import("WINSPOOL.DRV", auto) */
  56.         public native static boolean DeletePort (String pName, int hWnd, String pPortName);
  57.  
  58.         /** @dll.import("WINSPOOL.DRV", auto) */
  59.         public native static boolean DeletePrintProcessor (String pName, String pEnvironment, String pPrintProcessorName);
  60.  
  61.         /** @dll.import("WINSPOOL.DRV", auto) */
  62.         public native static boolean DeletePrintProvidor (String pName, String pEnvironment, String pPrintProvidorName);
  63.  
  64.         /** @dll.import("WINSPOOL.DRV",auto) */
  65.         public native static boolean DeletePrinter (int hPrinter);
  66.  
  67.         /** @dll.import("WINSPOOL.DRV", auto) */
  68.         public native static boolean DeletePrinterConnection (String pName);
  69.  
  70.         /** @dll.import("WINSPOOL.DRV", auto) */
  71.         public native static int DeletePrinterData (int hPrinter, String pValueName);
  72.  
  73.         /** @dll.import("WINSPOOL.DRV", auto) */
  74.         public native static boolean DeletePrinterDriver (String pName, String pEnvironment, String pDriverName);
  75.  
  76.         /** @dll.import("WINSPOOL.DRV",auto) */
  77.         public native static boolean EndDocPrinter (int hPrinter);
  78.  
  79.         /** @dll.import("WINSPOOL.DRV",auto) */
  80.         public native static boolean EndPagePrinter (int hPrinter);
  81.  
  82.         /** @dll.import("WINSPOOL.DRV",auto) */
  83.         public native static boolean EnumForms (int hPrinter, int Level, Object pForm, int cbBuf, int[] pcbNeeded, int[] pcReturned);
  84.  
  85.         /** @dll.import("WINSPOOL.DRV",auto) */
  86.         public native static boolean EnumJobs (int hPrinter, int FirstJob, int NoJobs, int Level, Object pJob, int cbBuf, int[] pcbNeeded, int[] pcReturned);
  87.  
  88.         /** @dll.import("WINSPOOL.DRV", auto) */
  89.         public native static boolean EnumMonitors (String pName, int Level, Object pMonitors, int cbBuf, int[] pcbNeeded, int[] pcReturned);
  90.  
  91.         /** @dll.import("WINSPOOL.DRV", auto) */
  92.         public native static boolean EnumPorts (String pName, int Level, Object pPorts, int cbBuf, int[] pcbNeeded, int[] pcReturned);
  93.  
  94.         /** @dll.import("WINSPOOL.DRV", auto) */
  95.         public native static boolean EnumPrintProcessorDatatypes (String pName, String pPrintProcessorName, int Level, Object pDatatypes, int cbBuf, int[] pcbNeeded, int[] pcReturned);
  96.  
  97.         /** @dll.import("WINSPOOL.DRV", auto) */
  98.         public native static boolean EnumPrintProcessors (String pName, String pEnvironment, int Level, Object pPrintProcessorInfo, int cbBuf, int[] pcbNeeded, int[] pcReturned);
  99.  
  100.         /** @dll.import("WINSPOOL.DRV", auto) */
  101.         public native static int EnumPrinterData (int hPrinter, int dwIndex, String pValueName, int cbValueName, int[] pcbValueName, int[] pType, Object pData, int cbData, int[] pcbData);
  102.  
  103.         /** @dll.import("WINSPOOL.DRV", auto) */
  104.         public native static boolean EnumPrinterDrivers (String pName, String pEnvironment, int Level, Object pDriverInfo, int cbBuf, int[] pcbNeeded, int[] pcReturned);
  105.  
  106.         /** @dll.import("WINSPOOL.DRV", auto) */
  107.         public native static boolean EnumPrinters (int Flags, String Name, int Level, Object pPrinterEnum, int cbBuf, int[] pcbNeeded, int[] pcReturned);
  108.  
  109.         /** @dll.import("WINSPOOL.DRV", auto, entrypoint="EnumPrinters") */
  110.         private native static boolean EnumPrinters_I (int Flags, String Name, int Level, int[] pPrinterEnum, int cbBuf, int[] pcbNeeded, int[] pcReturned);
  111.  
  112.  
  113.         private static boolean EnumPrintersWorker (Class PrinterStructClass, int Flags, String Name, int Level, PRINTER_INFO[] pPrinterEnum, int cbBuf, int[] pcbNeeded, int[] pcReturned)
  114.         {
  115.             PRINTER_INFO pinfo;
  116.             try {
  117.                 pinfo = (PRINTER_INFO)(PrinterStructClass.newInstance());
  118.             } catch (Exception ie) {
  119.                 throw new OutOfMemoryError(ie.toString());
  120.             }
  121.             int numSlots = pinfo.numSlots();
  122.  
  123.  
  124.             if (pPrinterEnum != null) {
  125.                 cbBuf = pPrinterEnum.length * (numSlots * 4);
  126.                 
  127.                 for (int i = 0; i < pPrinterEnum.length; i++) {
  128.                     try {
  129.                        if (pPrinterEnum[i] == null) {
  130.                            pPrinterEnum[i] = (PRINTER_INFO) (PrinterStructClass.newInstance());
  131.                        }
  132.                     } catch (Exception ie) {
  133.                        throw new OutOfMemoryError(ie.toString());
  134.                     }
  135.                 }
  136.             }
  137.             int[] tempbuf = pPrinterEnum != null ? new int[numSlots * pPrinterEnum.length] : null;
  138.             boolean rv = EnumPrinters_I(Flags, Name, Level, tempbuf, cbBuf, pcbNeeded, pcReturned);
  139.             if (rv) {
  140.                 if (pPrinterEnum != null) {
  141.                     if (pcReturned[0] <= pPrinterEnum.length) {
  142.                         int idx = 0;
  143.                         for (int i = 0; i < pcReturned[0]; i++) {
  144.                             pPrinterEnum[i].copyFromNative(tempbuf, idx);
  145.                             idx += numSlots;
  146.                         }
  147.                     }
  148.                 }
  149.             }
  150.             return rv;
  151.         }
  152.  
  153.  
  154.         public static boolean EnumPrinters (int Flags, String Name, int Level, PRINTER_INFO_1[] pPrinterEnum, int cbBuf, int[] pcbNeeded, int[] pcReturned)
  155.         {
  156.             return EnumPrintersWorker(PRINTER_INFO_1.class, Flags, Name, Level, (PRINTER_INFO[])pPrinterEnum, cbBuf, pcbNeeded, pcReturned);
  157.         }
  158.  
  159.  
  160.         public static boolean EnumPrinters (int Flags, String Name, int Level, PRINTER_INFO_2[] pPrinterEnum, int cbBuf, int[] pcbNeeded, int[] pcReturned)
  161.         {
  162.             return EnumPrintersWorker(PRINTER_INFO_2.class, Flags, Name, Level, (PRINTER_INFO[])pPrinterEnum, cbBuf, pcbNeeded, pcReturned);
  163.         }
  164.  
  165.  
  166.         public static boolean EnumPrinters (int Flags, String Name, int Level, PRINTER_INFO_4[] pPrinterEnum, int cbBuf, int[] pcbNeeded, int[] pcReturned)
  167.         {
  168.             return EnumPrintersWorker(PRINTER_INFO_4.class, Flags, Name, Level, (PRINTER_INFO[])pPrinterEnum, cbBuf, pcbNeeded, pcReturned);
  169.         }
  170.  
  171.  
  172.         public static boolean EnumPrinters (int Flags, String Name, int Level, PRINTER_INFO_5[] pPrinterEnum, int cbBuf, int[] pcbNeeded, int[] pcReturned)
  173.         {
  174.             return EnumPrintersWorker(PRINTER_INFO_5.class, Flags, Name, Level, (PRINTER_INFO[])pPrinterEnum, cbBuf, pcbNeeded, pcReturned);
  175.         }
  176.  
  177.  
  178.  
  179.         /** @dll.import("WINSPOOL.DRV",auto) */
  180.         public native static boolean FindClosePrinterChangeNotification (int hChange);
  181.  
  182.         /** @dll.import("WINSPOOL.DRV", auto) */
  183.         public native static boolean GetForm (int hPrinter, String pFormName, int Level, Object pForm, int cbBuf, int[] pcbNeeded);
  184.  
  185.         /** @dll.import("WINSPOOL.DRV",auto) */
  186.         public native static boolean GetJob (int hPrinter, int JobId, int Level, Object pJob, int cbBuf, int[] pcbNeeded);
  187.  
  188.         /** @dll.import("WINSPOOL.DRV", auto) */
  189.         public native static boolean GetPrintProcessorDirectory (String pName, String pEnvironment, int Level, Object pPrintProcessorInfo, int cbBuf, int[] pcbNeeded);
  190.  
  191.         /** @dll.import("WINSPOOL.DRV", auto) */
  192.         public native static int GetPrinterData (int hPrinter, String pValueName, int[] pType, Object pData, int nSize, int[] pcbNeeded);
  193.  
  194.         /** @dll.import("WINSPOOL.DRV", auto) */
  195.         public native static boolean GetPrinterDriverDirectory (String pName, String pEnvironment, int Level, Object pDriverDirectory, int cbBuf, int[] pcbNeeded);
  196.  
  197.         /** @dll.import("WINSPOOL.DRV", auto) */
  198.         public native static boolean GetPrinterDriver (int hPrinter, String pEnvironment, int Level, Object pDriverInfo, int cbBuf, int[] pcbNeeded);
  199.  
  200.         /** @dll.import("WINSPOOL.DRV",auto) */
  201.         public native static boolean GetPrinter (int hPrinter, int Level, Object pPrinter, int cbBuf, int[] pcbNeeded);
  202.  
  203.         /** @dll.import("WINSPOOL.DRV", auto) */
  204.         public native static boolean OpenPrinter (String pPrinterName, int[] phPrinter, PRINTER_DEFAULTS pDefault);
  205.  
  206.         /** @dll.import("WINSPOOL.DRV", auto) */
  207.         public native static int PrinterMessageBox (int hPrinter, int Error, int hWnd, String pText, String pCaption, int dwType);
  208.  
  209.         /** @dll.import("WINSPOOL.DRV",auto) */
  210.         public native static boolean ReadPrinter (int hPrinter, Object pBuf, int cbBuf, int[] pNoBytesRead);
  211.  
  212.         /** @dll.import("WINSPOOL.DRV",auto) */
  213.         public native static boolean ResetPrinter (int hPrinter, PRINTER_DEFAULTS pDefault);
  214.  
  215.         /** @dll.import("WINSPOOL.DRV",auto) */
  216.         public native static boolean ScheduleJob (int hPrinter, int JobId);
  217.  
  218.         /** @dll.import("WINSPOOL.DRV", auto) */
  219.         public native static boolean SetForm (int hPrinter, String pFormName, int Level, FORM_INFO_1 pForm);
  220.  
  221.         /** @dll.import("WINSPOOL.DRV",auto) */
  222.         public native static boolean SetJob (int hPrinter, int JobId, int Level, Object pJob, int Command);
  223.  
  224.         /** @dll.import("WINSPOOL.DRV",auto) */
  225.         public native static boolean SetPort (String pName, String pPortName, int dwLevel, Object pPortInfo);
  226.  
  227.         /** @dll.import("WINSPOOL.DRV", auto) */
  228.         public native static int SetPrinterData (int hPrinter, String pValueName, int Type, Object pData, int cbData);
  229.  
  230.         /** @dll.import("WINSPOOL.DRV",auto) */
  231.         public native static boolean SetPrinter (int hPrinter, int Level, Object pPrinter, int Command);
  232.  
  233.         /** @dll.import("WINSPOOL.DRV",auto) */
  234.         public native static int StartDocPrinter (int hPrinter, int Level, Object pDocInfo);
  235.  
  236.         /** @dll.import("WINSPOOL.DRV",auto) */
  237.         public native static boolean StartPagePrinter (int hPrinter);
  238.  
  239.         /** @dll.import("WINSPOOL.DRV",auto) */
  240.         public native static int WaitForPrinterChange (int hPrinter, int Flags);
  241.  
  242.         /** @dll.import("WINSPOOL.DRV",auto) */
  243.         public native static boolean WritePrinter (int hPrinter, Object pBuf, int cbBuf, int[] pcWritten);
  244. }
  245.  
  246.