home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vp21beta.zip / WRTLSRC.RAR / WINSPOOL.PAS < prev   
Pascal/Delphi Source File  |  2000-08-15  |  35KB  |  858 lines

  1. //█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
  2. //█                                                      █
  3. //█     Virtual Pascal Runtime Library.  Version 2.1     █
  4. //█     Windows Print API interface unit                 █
  5. //█     ─────────────────────────────────────────────────█
  6. //█     Copyright (C) 1999-2000 vpascal.com              █
  7. //█                                                      █
  8. //▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  9.  
  10. unit WinSpool;
  11.  
  12. {&AlignRec+,StdCall+,SmartLink+,OrgName+,Use32-}
  13.  
  14. interface
  15.  
  16. uses
  17.   Windows;
  18.  
  19. type
  20.   PPrinterInfo1 = ^TPrinterInfo1;
  21.   TPrinterInfo1 = record
  22.     Flags:        DWord;
  23.     pDescription: PChar;
  24.     pName:        PChar;
  25.     pComment:     PChar;
  26.   end;
  27.  
  28.   PPrinterInfo2 = ^TPrinterInfo2;
  29.   TPrinterInfo2 = record
  30.     pServerName:     PChar;
  31.     pPrinterName:    PChar;
  32.     pShareName:      PChar;
  33.     pPortName:       PChar;
  34.     pDriverName:     PChar;
  35.     pComment:        PChar;
  36.     pLocation:       PChar;
  37.     pDevMode:        PDeviceMode;
  38.     pSepFile:        PChar;
  39.     pPrintProcessor: PChar;
  40.     pDatatype:       PChar;
  41.     pParameters:     PChar;
  42.     pSecurityDescriptor: PSecurityDescriptor;
  43.     Attributes:      DWord;
  44.     Priority:        DWord;
  45.     DefaultPriority: DWord;
  46.     StartTime:       DWord;
  47.     UntilTime:       DWord;
  48.     Status:          DWord;
  49.     cJobs:           DWord;
  50.     AveragePPM:      DWord;
  51.   end;
  52.  
  53.   PPrinterInfo3 = ^TPrinterInfo3;
  54.   TPrinterInfo3 = record
  55.     pSecurityDescriptor: PSecurityDescriptor;
  56.   end;
  57.  
  58.   PPrinterInfo4 = ^TPrinterInfo4;
  59.   TPrinterInfo4 = record
  60.     pPrinterName: PChar;
  61.     pServerName:  PChar;
  62.     Attributes:   DWord;
  63.   end;
  64.  
  65.   PPrinterInfo5 = ^TPrinterInfo5;
  66.   TPrinterInfo5 = record
  67.     pPrinterName: PChar;
  68.     pPortName:    PChar;
  69.     Attributes:   DWord;
  70.     DeviceNotSelectedTimeout: DWord;
  71.     TransmissionRetryTimeout: DWord;
  72.   end;
  73.  
  74.   PPrinterInfo6 = ^TPrinterInfo6;
  75.   TPrinterInfo6 = record
  76.     dwStatus: DWord;
  77.   end;
  78.  
  79.   PPrinterInfo7 = ^TPrinterInfo7;
  80.   TPrinterInfo7 = record
  81.     pszObjectGUID: PChar;
  82.     dwAction:      DWord;
  83.   end;
  84.  
  85. const
  86.   dsprint_Publish               = 1;
  87.   dsprint_Update                = 2;
  88.   dsprint_Unpublish             = 3;
  89.  
  90.   printer_Control_Pause         = 1;
  91.   printer_Control_Resume        = 2;
  92.   printer_Control_Purge         = 3;
  93.   printer_Control_Set_Status    = 4;
  94.  
  95.   printer_Status_Paused         = $00000001;
  96.   printer_Status_Error          = $00000002;
  97.   printer_Status_Pending_Deletion = $00000004;
  98.   printer_Status_Paper_Jam      = $00000008;
  99.   printer_Status_Paper_Out      = $00000010;
  100.   printer_Status_Manual_Feed    = $00000020;
  101.   printer_Status_Paper_Problem  = $00000040;
  102.   printer_Status_Offline        = $00000080;
  103.   printer_Status_IO_Active      = $00000100;
  104.   printer_Status_Busy           = $00000200;
  105.   printer_Status_Printing       = $00000400;
  106.   printer_Status_Output_Bin_Full = $00000800;
  107.   printer_Status_Not_Available  = $00001000;
  108.   printer_Status_Waiting        = $00002000;
  109.   printer_Status_Processing     = $00004000;
  110.   printer_Status_Initializing   = $00008000;
  111.   printer_Status_Warming_Up     = $00010000;
  112.   printer_Status_Toner_Low      = $00020000;
  113.   printer_Status_No_Toner       = $00040000;
  114.   printer_Status_Page_Punt      = $00080000;
  115.   printer_Status_User_Intervention = $00100000;
  116.   printer_Status_Out_Of_Memory  = $00200000;
  117.   printer_Status_Door_Open      = $00400000;
  118.   printer_Status_Server_Unknown = $00800000;
  119.   printer_Status_Power_Save     = $01000000;
  120.  
  121.   printer_Attribute_Queued      = $00000001;
  122.   printer_Attribute_Direct      = $00000002;
  123.   printer_Attribute_Default     = $00000004;
  124.   printer_Attribute_Shared      = $00000008;
  125.   printer_Attribute_Network     = $00000010;
  126.   printer_Attribute_Hidden      = $00000020;
  127.   printer_Attribute_Local       = $00000040;
  128.  
  129.   printer_Attribute_Enable_Devq = $00000080;
  130.   printer_Attribute_KeepprintedjobS = $00000100;
  131.   printer_Attribute_Do_Complete_First = $00000200;
  132.  
  133.   printer_Attribute_Work_Offline = $00000400;
  134.   printer_Attribute_Enable_Bidi = $00000800;
  135.   printer_Attribute_Raw_Only    = $00001000;
  136.   printer_Attribute_Published   = $00002000;
  137.  
  138.  
  139.   no_Priority                   = 0;
  140.   max_Priority                  = 99;
  141.   min_Priority                  = 1;
  142.   def_Priority                  = 1;
  143.  
  144. type
  145.   PJobInfo1 = ^TJobInfo1;
  146.   TJobInfo1 = record
  147.     JobId:        DWord;
  148.     pPrinterName: PChar;
  149.     pMachineName: PChar;
  150.     pUserName:    PChar;
  151.     pDocument:    PChar;
  152.     pDatatype:    PChar;
  153.     pStatus:      PChar;
  154.     Status:       DWord;
  155.     Priority:     DWord;
  156.     Position:     DWord;
  157.     TotalPages:   DWord;
  158.     PagesPrinted: DWord;
  159.     Submitted:    TSystemTime;
  160.   end;
  161.  
  162.   PJobInfo2 = ^TJobInfo2;
  163.   TJobInfo2 = record
  164.     JobId:                DWord;
  165.     pPrinterName:         PChar;
  166.     pMachineName:         PChar;
  167.     pUserName:            PChar;
  168.     pDocument:            PChar;
  169.     pNotifyName:          PChar;
  170.     pDatatype:            PChar;
  171.     pPrintProcessor:      PChar;
  172.     pParameters:          PChar;
  173.     pDriverName:          PChar;
  174.     pDevMode:             PDeviceMode;
  175.     pStatus:              PChar;
  176.     PSecurityDescriptor:  pSecurityDescriptor;
  177.     Status:               DWord;
  178.     Priority:             DWord;
  179.     Position:             DWord;
  180.     StartTime:            DWord;
  181.     UntilTime:            DWord;
  182.     TotalPages:           DWord;
  183.     Size:                 DWord;
  184.     Submitted:            TSystemTime;  // Time the job was spooled
  185.     Time:                 DWord;        // How many seconds the job has been printing
  186.     PagesPrinted:         DWord;
  187.   end;
  188.  
  189.   PJobInfo3 = ^TJobInfo3;
  190.   TJobInfo3 = record
  191.     JobId:     DWord;
  192.     NextJobId: DWord;
  193.     Reserved:  DWord;
  194.   end;
  195.  
  196. const
  197.   job_Control_Pause             = 1;
  198.   job_Control_Resume            = 2;
  199.   job_Control_Cancel            = 3;
  200.   job_Control_Restart           = 4;
  201.   job_Control_Delete            = 5;
  202.   job_Control_Sent_To_Printer   = 6;
  203.   job_Control_Last_Page_Ejected = 7;
  204.  
  205.   job_Status_Paused             = $00000001;
  206.   job_Status_Error              = $00000002;
  207.   job_Status_Deleting           = $00000004;
  208.   job_Status_Spooling           = $00000008;
  209.   job_Status_Printing           = $00000010;
  210.   job_Status_Offline            = $00000020;
  211.   job_Status_Paperout           = $00000040;
  212.   job_Status_Printed            = $00000080;
  213.   job_Status_Deleted            = $00000100;
  214.   job_Status_Blocked_Devq       = $00000200;
  215.   job_Status_User_Intervention  = $00000400;
  216.   job_Status_Restart            = $00000800;
  217.  
  218.   job_Position_Unspecified      = 0;
  219.  
  220. type
  221.   PAddJobInfo1 = ^TAddJobInfo1;
  222.   TAddJobInfo1 = record
  223.     Path:  PChar;
  224.     JobId: DWord;
  225.   end;
  226.  
  227.   PDriverInfo1 = ^TDriverInfo1;
  228.   TDriverInfo1 = record
  229.     pName: PChar;              // QMS 810
  230.   end;
  231.  
  232.   PDriverInfo2 = ^TDriverInfo2;
  233.   TDriverInfo2 = record
  234.     cVersion:     DWord;
  235.     pName:        PChar;  // QMS 810
  236.     pEnvironment: PChar;  // Win32 x86
  237.     pDriverPath:  PChar;  // c:\drivers\pscript.dll
  238.     pDataFile:    PChar;  // c:\drivers\QMS810.PPD
  239.     pConfigFile:  PChar;  // c:\drivers\PSCRPTUI.DLL
  240.   end;
  241.  
  242.   PDriverInfo3 = ^TDriverInfo3;
  243.   TDriverInfo3 = record
  244.     cVersion:         DWord;
  245.     pName:            PChar; // QMS 810
  246.     pEnvironment:     PChar; // Win32 x86
  247.     pDriverPath:      PChar; // c:\drivers\pscript.dll
  248.     pDataFile:        PChar; // c:\drivers\QMS810.PPD
  249.     pConfigFile:      PChar; // c:\drivers\PSCRPTUI.DLL
  250.     pHelpFile:        PChar; // c:\drivers\PSCRPTUI.HLP
  251.     pDependentFiles:  PChar; // PSCRIPT.DLL\0QMS810.PPD\0PSCRIPTUI.DLL\0PSCRIPTUI.HLP\0PSTEST.TXT\0\0
  252.     pMonitorName:     PChar; // "PJL monitor"
  253.     pDefaultDataType: PChar; // "EMF"
  254.   end;
  255.  
  256. const
  257. // FLAGS for DeletePrinterDriverEx.
  258.   dpd_Delete_Unused_Files       = $00000001;
  259.   dpd_Delete_Specific_Version   = $00000002;
  260.   dpd_Delete_All_Files          = $00000004;
  261.  
  262. // FLAGS for AddPrinterDriverEx.
  263.   apd_Strict_Upgrade            = $00000001;
  264.   apd_Strict_DowngradE          = $00000002;
  265.   apd_Copy_All_Files            = $00000004;
  266.   apd_Copy_New_Files            = $00000008;
  267.  
  268. type
  269.   PDocInfo1 = ^TDocInfo1;
  270.   TDocInfo1 = record
  271.     pDocName:    PChar;
  272.     pOutputFile: PChar;
  273.     pDatatype:   PChar;
  274.   end;
  275.  
  276.   PFormInfo1 = ^TFormInfo1;
  277.   TFormInfo1 = record
  278.     Flags:         DWord;
  279.     pName:         PChar;
  280.     Size:          TSize;
  281.     ImageableArea: TRect;
  282.   end;
  283.  
  284.   PDocInfo2 = ^TDocInfo2;
  285.   TDocInfo2 = record
  286.     pDocName:    PChar;
  287.     pOutputFile: PChar;
  288.     pDatatype:   PChar;
  289.     dwMode:      DWord;
  290.     JobId:       DWord;
  291.   end;
  292.  
  293. const
  294.   di_Channel                    = 1;    // start direct read/write channel,
  295.   di_Read_Spool_Job             = 3;
  296.   form_User                     = $00000000;
  297.   form_Builtin                  = $00000001;
  298.   form_Printer                  = $00000002;
  299.  
  300. type
  301.   PPrintProcessorInfo1 = ^TPrintProcessorInfo1;
  302.   TPrintProcessorInfo1 = record
  303.     pName: PChar;
  304.   end;
  305.  
  306.   PPrintProcessorCaps1 = ^TPrintProcessorCaps1;
  307.   TPrintProcessorCaps1 = record
  308.     dwLevel:          DWord;
  309.     dwNupOptions:     DWord;
  310.     dwPageOrderFlags: DWord;
  311.     dwNumberOfCopies: DWord;
  312.   end;
  313.  
  314.   PPortInfo1 = ^TPortInfo1;
  315.   TPortInfo1 = record
  316.     pName: PChar;
  317.   end;
  318.  
  319.   PPortInfo2 = ^TPortInfo2;
  320.   TPortInfo2 = record
  321.     pPortName:    PChar;
  322.     pMonitorName: PChar;
  323.     pDescription: PChar;
  324.     fPortType:    DWord;
  325.     Reserved:     DWord;
  326.   end;
  327.  
  328. const
  329.   port_Type_Write               = $0001;
  330.   port_Type_Read                = $0002;
  331.   port_Type_Redirected          = $0004;
  332.   port_Type_Net_Attached        = $0008;
  333.  
  334. type
  335.   PPortInfo3 = ^TPortInfo3;
  336.   TPortInfo3 = record
  337.     dwStatus:   DWord;
  338.     pszStatus:  PChar;
  339.     dwSeverity: DWord;
  340.   end;
  341.  
  342. const
  343.   port_Status_Type_Error        = 1;
  344.   port_Status_Type_Warning      = 2;
  345.   port_Status_Type_Info         = 3;
  346.  
  347.   port_Status_Offline           = 1;
  348.   port_Status_Paper_Jam         = 2;
  349.   port_Status_Paper_Out         = 3;
  350.   port_Status_Output_Bin_Full   = 4;
  351.   port_Status_Paper_Problem     = 5;
  352.   port_Status_No_Toner          = 6;
  353.   port_Status_Door_Open         = 7;
  354.   port_Status_User_Intervention = 8;
  355.   port_Status_Out_Of_Memory     = 9;
  356.  
  357.   port_Status_Toner_Low         = 10;
  358.  
  359.   port_Status_Warming_Up        = 11;
  360.   port_Status_Power_Save        = 12;
  361.  
  362. type
  363.   PMonitorInfo1 = ^TMonitorInfo1;
  364.   TMonitorInfo1 = record
  365.     pName: PChar;
  366.   end;
  367.  
  368.   PMonitorInfo2 = ^TMonitorInfo2;
  369.   TMonitorInfo2 = record
  370.     pName:        PChar;
  371.     pEnvironment: PChar;
  372.     pDLLName:     PChar;
  373.   end;
  374.  
  375.   PDataTypesInfo1 = ^TDataTypesInfo1;
  376.   TDataTypesInfo1 = record
  377.     pName: PChar;
  378.   end;
  379.  
  380.   PPrinterDefaults = ^TPrinterDefaults;
  381.   TPrinterDefaults = record
  382.     pDatatype:     PChar;
  383.     pDevMode:      PDeviceMode;
  384.     DesiredAccess: ACCESS_MASK;
  385.   end;
  386.  
  387.   PPrinterEnumValues = ^TPrinterEnumValues;
  388.   TPrinterEnumValues = record
  389.     pValueName:  PChar;
  390.     cbValueName: DWord;
  391.     dwType:      DWord;
  392.     pData:       Pointer;
  393.     cbData:      DWord;
  394.   end;
  395.  
  396. function EnumPrinters(Flags: DWord; Name: PChar; Level: DWord; pPrinterEnum: Pointer; cbBuf: DWord; var pcbNeeded,pcReturned: DWord): Bool;
  397.  
  398. const
  399.   printer_Enum_Default          = $00000001;
  400.   printer_Enum_Local            = $00000002;
  401.   printer_Enum_Connections      = $00000004;
  402.   printer_Enum_Favorite         = $00000004;
  403.   printer_Enum_Name             = $00000008;
  404.   printer_Enum_Remote           = $00000010;
  405.   printer_Enum_Shared           = $00000020;
  406.   printer_Enum_Network          = $00000040;
  407.  
  408.   printer_Enum_Expand           = $00004000;
  409.   printer_Enum_Container        = $00008000;
  410.  
  411.   printer_Enum_Iconmask         = $00ff0000;
  412.   printer_Enum_Icon1            = $00010000;
  413.   printer_Enum_Icon2            = $00020000;
  414.   printer_Enum_Icon3            = $00040000;
  415.   printer_Enum_Icon4            = $00080000;
  416.   printer_Enum_Icon5            = $00100000;
  417.   printer_Enum_Icon6            = $00200000;
  418.   printer_Enum_Icon7            = $00400000;
  419.   printer_Enum_Icon8            = $00800000;
  420.  
  421. function OpenPrinter(pPrinterName: PChar; var phPrinter: THandle; pDefault: PPrinterDefaults): Bool;
  422. function ResetPrinter(hPrinter: THandle; pDefault: PPrinterDefaults): Bool;
  423. function SetJob(hPrinter: THandle; JobId,Level: DWord; pJob: Pointer; Command: DWord): Bool;
  424. function GetJob(hPrinter: THandle; JobId,Level: DWord; pJob: Pointer; cbBuf: DWord; pcbNeeded: PDWord): Bool;
  425. function EnumJobs(hPrinter: THandle; FirstJob,NoJobs,Level: DWord; pJob: Pointer; cbBuf: DWord; var pcbNeeded,pcReturned: DWord): Bool;
  426. function AddPrinter(pName: PChar; Level: DWord; pPrinter: Pointer): THandle;
  427. function DeletePrinter(hPrinter: THandle): Bool;
  428. function SetPrinter(hPrinter: THandle; Level: DWord; pPrinter: Pointer; Command: DWord): Bool;
  429. function GetPrinter(hPrinter: THandle; Level: DWord; pPrinter: Pointer; cbBuf: DWord; pcbNeeded: PDWord): Bool;
  430. function AddPrinterDriver(pName: PChar; Level: DWord; pDriverInfo: Pointer): Bool;
  431. function AddPrinterDriverEx(pName: PChar; Level: DWord; pDriverInfo: Pointer; dwFileCopyFlags: DWord): Bool;
  432. function EnumPrinterDrivers(pName,pEnvironment: PChar; Level: DWord; pDriverInfo: Pointer; cbBuf: DWord; var pcbNeeded,pcReturned: DWord): Bool;
  433. function GetPrinterDriver(hPrinter: THandle; pEnvironment: PChar; Level: DWord; pDriverInfo: Pointer; cbBuf: DWord; var pcbNeeded: DWord): Bool;
  434. function GetPrinterDriverDirectory(pName,pEnvironment: PChar; Level: DWord; pDriverDirectory: Pointer; cbBuf: DWord; var pcbNeeded: DWord): Bool;
  435. function DeletePrinterDriver(pName,pEnvironment,pDriverName: PChar): Bool;
  436. function DeletePrinterDriverEx(pName,pEnvironment,pDriverName: PChar; dwDeleteFlag,dwVersionFlag: DWord): Bool;
  437. function AddPerMachineConnection(pServer,pPrinterName,pPrintServer,pProvider: PChar): Bool;
  438. function DeletePerMachineConnection(pServer,pPrinterName: PChar): Bool;
  439. function EnumPerMachineConnections(pServer: PChar; pPrinterEnum: Pointer; cbBuf: DWord; var pcbNeeded: DWord): Bool;
  440. function AddPrintProcessor(pName,pEnvironment,pPathName,pPrintProcessorName: PChar): Bool;
  441. function EnumPrintProcessors(pName,pEnvironment: PChar; Level: DWord; pPrintProcessorInfo: Pointer; cbBuf: DWord; var pcbNeeded,pcReturned: DWord): Bool;
  442. function GetPrintProcessorDirectory(pName, pEnvironment: PChar; Level: DWord; pPrintProcessorInfo: Pointer; cbBuf: DWord; var pcbNeeded: DWord): Bool;
  443. function EnumPrintProcessorDatatypes(pName, pPrintProcessorName: PChar; Level: DWord; pDatatypes: Pointer; cbBuf: DWord; var pcbNeeded, pcReturned: DWord): Bool;
  444. function DeletePrintProcessor(pName, pEnvironment, pPrintProcessorName: PChar): Bool;
  445. function StartDocPrinter(hPrinter: THandle; Level: DWord; pDocInfo: Pointer): DWord;
  446. function StartPagePrinter(hPrinter: THandle): Bool;
  447. function WritePrinter(hPrinter: THandle; pBuf: Pointer; cbBuf: DWord; var pcWritten: DWord): Bool;
  448. function EndPagePrinter(hPrinter: THandle): Bool;
  449. function AbortPrinter(hPrinter: THandle): Bool;
  450. function ReadPrinter(hPrinter: THandle; pBuf: Pointer; cbBuf: DWord; var pNoBytesRead: DWord): Bool;
  451. function EndDocPrinter(hPrinter: THandle): Bool;
  452. function AddJob(hPrinter: THandle; Level: DWord; pData: Pointer; cbBuf: DWord; var pcbNeeded: DWord): Bool;
  453. function ScheduleJob(hPrinter: THandle; JobId: DWord): Bool;
  454. function PrinterProperties(hWnd: HWnd; hPrinter: THandle): Bool;
  455. function DocumentProperties(hWnd: HWnd; hPrinter: THandle; pDeviceName: PChar; const pDevModeOutput: TDeviceMode; var pDevModeInput: TDeviceMode; fMode: DWord): Longint;
  456. function AdvancedDocumentProperties(hWnd: HWnd; hPrinter: THandle; pDeviceName: PChar; pDevModeOutput, pDevModeInput: PDeviceMode): Longint;
  457. function GetPrinterData(hPrinter: THandle; pValueName: PChar; pType: PDWord; pData: Pointer; nSize: DWord; var pcbNeeded: DWord): DWord;
  458. function GetPrinterDataEx(hPrinter: THandle; pKeyName,pValueName: PChar; pType: PDWord; pData: Pointer; nSize: DWord; var pcbNeeded: DWord): DWord;
  459. function EnumPrinterData(hPrinter: THandle; dwIndex: DWord; pValueName: PChar; cbValueName: DWord; var pcbValueName, pType: DWord; pData: PByte; cbData: DWord; pcbData: PDWord): DWord;
  460. function EnumPrinterDataEx(hPrinter: THandle; pKeyName: PChar; pEnumValues: Pointer; cbEnumValues: DWord; var pcbEnumValues,pnEnumValues: DWord): DWord;
  461. function EnumPrinterKey(hPrinter: THandle; pKeyName,pSubkey: PChar; cbSubkey: DWord; pcbSubkey: PDWord): DWord;
  462. function SetPrinterData(hPrinter: THandle; pValueName: PChar; dwType: DWord; pData: Pointer; cbData: DWord): DWord;
  463. function SetPrinterDataEx(hPrinter: THandle; pKeyName,pValueName: PChar; dwType: DWord; pData: Pointer; cbData: DWord): DWord;
  464. function DeletePrinterData(hPrinter: THandle; pValueName: PChar): DWord;
  465. function DeletePrinterDataEx(hPrinter: THandle; pKeyName,pValueName: PChar): DWord;
  466. function DeletePrinterKey(hPrinter: THandle; pKeyName: PChar): DWord;
  467.  
  468. const
  469.   PRINTER_NOTIFY_TYPE           = $00;
  470.   JOB_NOTIFY_TYPE               = $01;
  471.  
  472.   printer_Notify_Field_Server_Name         = $00;
  473.   printer_Notify_Field_Printer_Name        = $01;
  474.   printer_Notify_Field_Share_Name          = $02;
  475.   printer_Notify_Field_Port_Name           = $03;
  476.   printer_Notify_Field_Driver_Name         = $04;
  477.   printer_Notify_Field_Comment             = $05;
  478.   printer_Notify_Field_Location            = $06;
  479.   printer_Notify_Field_Devmode             = $07;
  480.   printer_Notify_Field_Sepfile             = $08;
  481.   printer_Notify_Field_Print_Processor     = $09;
  482.   printer_Notify_Field_Parameters          = $0A;
  483.   printer_Notify_Field_Datatype            = $0B;
  484.   printer_Notify_Field_Security_Descriptor = $0C;
  485.   printer_Notify_Field_Attributes          = $0D;
  486.   printer_Notify_Field_Priority            = $0E;
  487.   printer_Notify_Field_Default_Priority    = $0F;
  488.   printer_Notify_Field_Start_Time          = $10;
  489.   printer_Notify_Field_Until_Time          = $11;
  490.   printer_Notify_Field_Status              = $12;
  491.   printer_Notify_Field_Status_String       = $13;
  492.   printer_Notify_Field_Cjobs               = $14;
  493.   printer_Notify_Field_Average_Ppm         = $15;
  494.   printer_Notify_Field_Total_Pages         = $16;
  495.   printer_Notify_Field_Pages_Printed       = $17;
  496.   printer_Notify_Field_Total_Bytes         = $18;
  497.   printer_Notify_Field_Bytes_Printed       = $19;
  498.   printer_Notify_Field_Object_Guid         = $1A;
  499.  
  500.   job_Notify_Field_Printer_Name            = $00;
  501.   job_Notify_Field_Machine_Name            = $01;
  502.   job_Notify_Field_Port_Name               = $02;
  503.   job_Notify_Field_User_Name               = $03;
  504.   job_Notify_Field_Notify_Name             = $04;
  505.   job_Notify_Field_Datatype                = $05;
  506.   job_Notify_Field_Print_Processor         = $06;
  507.   job_Notify_Field_Parameters              = $07;
  508.   job_Notify_Field_Driver_Name             = $08;
  509.   job_Notify_Field_Devmode                 = $09;
  510.   job_Notify_Field_Status                  = $0A;
  511.   job_Notify_Field_Status_String           = $0B;
  512.   job_Notify_Field_Security_Descriptor     = $0C;
  513.   job_Notify_Field_Document                = $0D;
  514.   job_Notify_Field_Priority                = $0E;
  515.   job_Notify_Field_Position                = $0F;
  516.   job_Notify_Field_Submitted               = $10;
  517.   job_Notify_Field_Start_Time              = $11;
  518.   job_Notify_Field_Until_Time              = $12;
  519.   job_Notify_Field_Time                    = $13;
  520.   job_Notify_Field_Total_Pages             = $14;
  521.   job_Notify_Field_Pages_Printed           = $15;
  522.   job_Notify_Field_Total_Bytes             = $16;
  523.   job_Notify_Field_Bytes_Printed           = $17;
  524.  
  525.  
  526. type
  527.   PPrinterNotifyOptionsType = ^TPrinterNotifyOptionsType;
  528.   TPrinterNotifyOptionsType = record
  529.     wType:     Word;
  530.     Reserved0: Word;
  531.     Reserved1: DWord;
  532.     Reserved2: DWord;
  533.     Count:     DWord;
  534.     pFields:   PWord;
  535.   end;
  536.  
  537.  
  538. const
  539.   printer_Notify_Options_Refresh = $01;
  540.  
  541. type
  542.   PPrinterNotifyOptions = ^TPrinterNotifyOptions;
  543.   TPrinterNotifyOptions = record
  544.     Version: DWord;
  545.     Flags:   DWord;
  546.     Count:   DWord;
  547.     pTypes:  PPrinterNotifyOptionsType;
  548.   end;
  549.  
  550. const
  551.   printer_Notify_Info_Discarded = $01;
  552.  
  553. type
  554.   PPrinterNotifyInfoData = ^TPrinterNotifyInfoData;
  555.   TPrinterNotifyInfoData = record
  556.     wType:      Word;
  557.     Field:      Word;
  558.     Reserved:   DWord;
  559.     Id:         DWord;
  560.     NotifyData: record
  561.       case Integer of
  562.         0: (adwData: array[0..1] of DWord);
  563.         1: (Data: record
  564.               cbBuf: DWord;
  565.               pBuf:  Pointer;
  566.             end);
  567.     end;
  568.   end;
  569.  
  570.   PPrinterNotifyInfo = ^TPrinterNotifyInfo;
  571.   TPrinterNotifyInfo = record
  572.     Version: DWord;
  573.     Flags:   DWord;
  574.     Count:   DWord;
  575.     aData: array[0..0] of TPrinterNotifyInfoData;
  576.   end;
  577.  
  578. function WaitForPrinterChange(hPrinter: THandle; Flags: DWord): DWord;
  579. function FindFirstPrinterChangeNotification(hPrinter: THandle; fdwFlags,fdwOptions: DWord; pPrinterNotifyOptions: Pointer): THandle;
  580. function FindNextPrinterChangeNotification(hChange: THandle; var pdwChange: DWord; pvReserved: Pointer; var ppPrinterNotifyInfo: Pointer): Bool;
  581. function FreePrinterNotifyInfo(pPrinterNotifyInfo: PPrinterNotifyInfo): Bool;
  582. function FindClosePrinterChangeNotification(hChange: THandle): Bool;
  583.  
  584. const
  585.   printer_Change_Add_Printer    = $00000001;
  586.   printer_Change_Set_Printer    = $00000002;
  587.   printer_Change_Delete_Printer = $00000004;
  588.   printer_Change_Failed_Connection_Printer = $00000008;
  589.   printer_Change_Printer        = $000000FF;
  590.   printer_Change_Add_Job        = $00000100;
  591.   printer_Change_Set_Job        = $00000200;
  592.   printer_Change_Delete_Job     = $00000400;
  593.   printer_Change_Write_Job      = $00000800;
  594.   printer_Change_Job            = $0000FF00;
  595.   printer_Change_Add_Form       = $00010000;
  596.   printer_Change_Set_Form       = $00020000;
  597.   printer_Change_Delete_Form    = $00040000;
  598.   printer_Change_Form           = $00070000;
  599.   printer_Change_Add_Port       = $00100000;
  600.   printer_Change_Configure_Port = $00200000;
  601.   printer_Change_Delete_Port    = $00400000;
  602.   printer_Change_Port           = $00700000;
  603.   printer_Change_Add_Print_Processor = $01000000;
  604.   printer_Change_Delete_Print_Processor = $04000000;
  605.   printer_Change_Print_Processor = $07000000;
  606.   printer_Change_Add_Printer_Driver = $10000000;
  607.   printer_Change_Set_Printer_Driver = $20000000;
  608.   printer_Change_Delete_Printer_Driver = $40000000;
  609.   printer_Change_Printer_Driver = $70000000;
  610.   printer_Change_Timeout        = $80000000;
  611.   printer_Change_All            = $7777FFFF;
  612.  
  613. function PrinterMessageBox(hPrinter: THandle; Error: DWord; hWnd: HWnd; pText,pCaption: PChar; dwType: DWord): DWord;
  614.  
  615. const
  616.   printer_Error_Information     = $80000000;
  617.   printer_Error_Warning         = $40000000;
  618.   printer_Error_Severe          = $20000000;
  619.  
  620.   printer_Error_Outofpaper      = $00000001;
  621.   printer_Error_Jam             = $00000002;
  622.   printer_Error_Outoftoner      = $00000004;
  623.  
  624. function ClosePrinter(hPrinter: THandle): Bool;
  625. function AddForm(hPrinter: THandle; Level: DWord; pForm: Pointer): Bool;
  626. function DeleteForm(hPrinter: THandle; pFormName: PChar): Bool;
  627. function GetForm(hPrinter: THandle; pFormName: PChar; Level: DWord; pForm: Pointer; cbBuf: DWord; var pcbNeeded: DWord): Bool;
  628. function SetForm(hPrinter: THandle; pFormName: PChar; Level: DWord; pForm: Pointer): Bool;
  629. function EnumForms(hPrinter: THandle; Level: DWord; pForm: Pointer; cbBuf: DWord; var pcbNeeded,pcReturned: DWord): Bool;
  630. function EnumMonitors(pName: PChar; Level: DWord; pMonitors: Pointer; cbBuf: DWord; var pcbNeeded,pcReturned: DWord): Bool;
  631. function AddMonitor(pName: PChar; Level: DWord; pMonitors: Pointer): Bool;
  632. function DeleteMonitor(pName, pEnvironment, pMonitorName: PChar): Bool;
  633. function EnumPorts(pName: PChar; Level: DWord; pPorts: Pointer; cbBuf: DWord; var pcbNeeded,pcReturned: DWord): Bool;
  634. function AddPort(pName: PChar; hWnd: HWnd; pMonitorName: PChar): Bool;
  635. function ConfigurePort(pName: PChar; hWnd: HWnd; pPortName: PChar): Bool;
  636. function DeletePort(pName: PChar; hWnd: HWnd; pPortName: PChar): Bool;
  637. function XcvData(hXcv: THandle; pszDataName: PChar{PWideChar}; pInputData: Pointer; cbInputData: DWord; pOutputData: Pointer; cbOutputData: DWord; pcbOutputNeeded,pdwStatus: PDWord): Bool;
  638. function SetPort(pName, pPortName: PChar; dwLevel: DWord; pPortInfo: Pointer): Bool;
  639. function AddPrinterConnection(pName: PChar): Bool;
  640. function DeletePrinterConnection(pName: PChar): Bool;
  641. function ConnectToPrinterDlg(hwnd: HWnd; Flags: DWord): THandle;
  642.  
  643. type
  644.   PProvidorInfo1 = ^TProvidorInfo1;
  645.   TProvidorInfo1 = record
  646.     pName:        PChar;
  647.     pEnvironment: PChar;
  648.     pDLLName:     PChar;
  649.   end;
  650.  
  651.  
  652. function AddPrintProvidor(pName: PChar; level: DWord; pProvidorInfo: Pointer): Bool;
  653. function DeletePrintProvidor(pName,pEnvironment,pPrintProvidorName: PChar): Bool;
  654.  
  655. // SetPrinterData and GetPrinterData Server Handle Key values
  656.  
  657. const
  658.   splreg_Default_Spool_Directory            = 'DefaultSpoolDirectory';
  659.   splreg_Port_Thread_Priority_Default       = 'PortThreadPriorityDefault';
  660.   splreg_Port_Thread_Priority               = 'PortThreadPriority';
  661.   splreg_Scheduler_Thread_Priority_Default  = 'SchedulerThreadPriorityDefault';
  662.   splreg_Scheduler_Thread_Priority          = 'SchedulerThreadPriority';
  663.   splreg_Beep_Enabled                       = 'BeepEnabled';
  664.   splreg_Net_Popup                          = 'NetPopup';
  665.   splreg_Event_Log                          = 'EventLog';
  666.   splreg_Major_Version                      = 'MajorVersion';
  667.   splreg_Minor_Version                      = 'MinorVersion';
  668.   splreg_Architecture                       = 'Architecture';
  669.   splreg_Os_Version                         = 'OSVersion';
  670.   splreg_Ds_Present                         = 'DsPresent';
  671.  
  672.   server_Access_Administer      = $00000001;
  673.   server_Access_Enumerate       = $00000002;
  674.  
  675.   printer_Access_Administer     = $00000004;
  676.   printer_Access_Use            = $00000008;
  677.  
  678.   job_Access_Administer         = $00000010;
  679.  
  680.  
  681. // Access rights for print servers
  682.  
  683.   server_All_Access             = standard_Rights_Required or server_Access_Administer or server_Access_Enumerate;
  684.   server_Read                   = standard_Rights_Read or server_Access_Enumerate;
  685.   server_Write                  = standard_Rights_Write or server_Access_Administer or server_Access_Enumerate;
  686.   server_Execute                = standard_Rights_Execute or server_Access_Enumerate;
  687.  
  688. // Access rights for printers
  689.  
  690.   printer_All_Access            = standard_Rights_Required or printer_Access_Administer or printer_Access_Use;
  691.   printer_Read                  = standard_Rights_Read or printer_Access_Use;
  692.   printer_Write                 = standard_Rights_Write or printer_Access_Use;
  693.   printer_Execute               = standard_Rights_Execute or printer_Access_Use;
  694.  
  695. // Access rights for jobs
  696.  
  697.   job_All_Access                = standard_Rights_Required or job_Access_Administer;
  698.   job_Read                      = standard_Rights_Read or job_Access_Administer;
  699.   job_Write                     = standard_Rights_Write or job_Access_Administer;
  700.   job_Execute                   = standard_Rights_Execute or job_Access_Administer;
  701.  
  702. // DS Print-Queue property tables
  703.  
  704. // Predefined Registry Keys used by Set/GetPrinterDataEx
  705.   splds_Spooler_Key             = 'DsSpooler';
  706.   splds_Driver_Key              = 'DsDriver';
  707.   splds_User_Key                = 'DsUser';
  708.  
  709.  
  710. // DS Print-Queue properties
  711.  
  712.   splds_Asset_Number            = 'assetNumber';
  713.   splds_Bytes_Per_Minute        = 'bytesPerMinute';
  714.   splds_Description             = 'description';
  715.   splds_Driver_Name             = 'driverName';
  716.   splds_Driver_Version          = 'driverVersion';
  717.   splds_Location                = 'location';
  718.   splds_Port_Name               = 'portName';
  719.   splds_Print_Attributes        = 'printAttributes';
  720.   splds_Print_Bin_Names         = 'printBinNames';
  721.   splds_Print_Collate           = 'printCollate';
  722.   splds_Print_Color             = 'printColor';
  723.   splds_Print_Duplex_Supported  = 'printDuplexSupported';
  724.   splds_Print_End_Time          = 'printEndTime';
  725.   splds_Printer_Class           = 'printQueue';
  726.   splds_Printer_Name            = 'printerName';
  727.   splds_Print_Keep_Printed_Jobs = 'printKeepPrintedJobs';
  728.   splds_Print_Language          = 'printLanguage';
  729.   splds_Print_Mac_Address       = 'printMACAddress';
  730.   splds_Print_Max_X_Extent      = 'printMaxXExtent';
  731.   splds_Print_Max_Y_Extent      = 'printMaxYExtent';
  732.   splds_Print_Max_Resolution_Supported = 'printMaxResolutionSupported';
  733.   splds_Print_Media_Ready       = 'printMediaReady';
  734.   splds_Print_Media_Supported   = 'printMediaSupported';
  735.   splds_Print_Memory            = 'printMemory';
  736.   splds_Print_Min_X_Extent      = 'printMinXExtent';
  737.   splds_Print_Min_Y_Extent      = 'printMinYExtent';
  738.   splds_Print_Network_Address   = 'printNetworkAddress';
  739.   splds_Print_Notify            = 'printNotify';
  740.   splds_Print_Number_Up         = 'printNumberUp';
  741.   splds_Print_Orientations_Supported = 'printOrientationsSupported';
  742.   splds_Print_Owner             = 'printOwner';
  743.   splds_Print_Rate              = 'printRate';
  744.   splds_Print_Rate_Unit         = 'printRateUnit';
  745.   splds_Print_Separator_File    = 'printSeparatorFile';
  746.   splds_Print_Share_Name        = 'printShareName';
  747.   splds_Print_Spooling          = 'printSpooling';
  748.   splds_Print_Stapling_Supported = 'printStaplingSupported';
  749.   splds_Print_Start_Time        = 'printStartTime';
  750.   splds_Print_Status            = 'printStatus';
  751.   splds_Priority                = 'priority';
  752.   splds_Server_Name             = 'serverName';
  753.   splds_Unc_Name                = 'uNCName';
  754.   splds_Url                     = 'url';
  755.   splds_Version_Number          = 'versionNumber';
  756.  
  757. //  -- Additional Print-Queue properties --
  758. //
  759. //  These properties are not defined in the default Directory Services Schema,
  760. //  but should be used when extending the Schema so a consistent interface is maintained.
  761.  
  762.   splds_Printer_Name_Aliases    = 'printerNameAliases'; // MULTI_SZ
  763.   splds_Printer_Locations       = 'printerLocations';   // MULTI_SZ
  764.   splds_Printer_Model           = 'printerModel';       // SZ
  765.  
  766.   printer_Html_View_Queue       = 0;
  767.   printer_Html_View_PrintProperties = 1;
  768.   printer_Html_View_Install     = 2;
  769.   printer_Html_View_JobProperties = 3;
  770.  
  771.  
  772. function SetPrinterHTMLView(hPrinter: THandle; dwView: DWord; lpszPath: PChar): DWord;
  773. function GetPrinterHTMLView(hPrinter: THandle; dwView: DWord; lpszPath: PChar; nSize: DWord; pcbNeeded: PDWord): DWord;
  774. {&OrgName-}
  775. function DeviceCapabilities(pDevice,pPort: PChar; fwCapability: Word; pOutput: PChar; DevMode: PDeviceMode): Integer;
  776. {&OrgName+}
  777.  
  778. implementation
  779.  
  780. function EnumPrinters;                  external;
  781. function OpenPrinter;                   external;
  782. function ResetPrinter;                  external;
  783. function SetJob;                        external;
  784. function GetJob;                        external;
  785. function EnumJobs;                      external;
  786. function AddPrinter;                    external;
  787. function DeletePrinter;                 external;
  788. function SetPrinter;                    external;
  789. function GetPrinter;                    external;
  790. function AddPrinterDriver;              external;
  791. function AddPrinterDriverEx;            external;
  792. function EnumPrinterDrivers;            external;
  793. function GetPrinterDriver;              external;
  794. function GetPrinterDriverDirectory;     external;
  795. function DeletePrinterDriver;           external;
  796. function DeletePrinterDriverEx;         external;
  797. function AddPerMachineConnection;       external;
  798. function DeletePerMachineConnection;    external;
  799. function EnumPerMachineConnections;     external;
  800. function AddPrintProcessor;             external;
  801. function EnumPrintProcessors;           external;
  802. function GetPrintProcessorDirectory;    external;
  803. function EnumPrintProcessorDatatypes;   external;
  804. function DeletePrintProcessor;          external;
  805. function StartDocPrinter;               external;
  806. function StartPagePrinter;              external;
  807. function WritePrinter;                  external;
  808. function EndPagePrinter;                external;
  809. function AbortPrinter;                  external;
  810. function ReadPrinter;                   external;
  811. function EndDocPrinter;                 external;
  812. function AddJob;                        external;
  813. function ScheduleJob;                   external;
  814. function PrinterProperties;             external;
  815. function DocumentProperties;            external;
  816. function AdvancedDocumentProperties;    external;
  817. function GetPrinterData;                external;
  818. function GetPrinterDataEx;              external;
  819. function EnumPrinterData;               external;
  820. function EnumPrinterDataEx;             external;
  821. function EnumPrinterKey;                external;
  822. function SetPrinterData;                external;
  823. function SetPrinterDataEx;              external;
  824. function DeletePrinterData;             external;
  825. function DeletePrinterDataEx;           external;
  826. function DeletePrinterKey;              external;
  827. function WaitForPrinterChange;          external;
  828. function FindFirstPrinterChangeNotification; external;
  829. function FindNextPrinterChangeNotification;  external;
  830. function FreePrinterNotifyInfo;         external;
  831. function FindClosePrinterChangeNotification; external;
  832. function PrinterMessageBox;             external;
  833. function ClosePrinter;                  external;
  834. function AddForm;                       external;
  835. function DeleteForm;                    external;
  836. function GetForm;                       external;
  837. function SetForm;                       external;
  838. function EnumForms;                     external;
  839. function EnumMonitors;                  external;
  840. function AddMonitor;                    external;
  841. function DeleteMonitor;                 external;
  842. function EnumPorts;                     external;
  843. function AddPort;                       external;
  844. function ConfigurePort;                 external;
  845. function DeletePort;                    external;
  846. function XcvData;                       external;
  847. function SetPort;                       external;
  848. function AddPrinterConnection;          external;
  849. function DeletePrinterConnection;       external;
  850. function ConnectToPrinterDlg;           external;
  851. function AddPrintProvidor;              external;
  852. function DeletePrintProvidor;           external;
  853. function SetPrinterHTMLView;            external;
  854. function GetPrinterHTMLView;            external;
  855. function DeviceCapabilities;            external;
  856.  
  857. end.
  858.