home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / ADSDK.ZIP / Samples / WinNT / PrintQueue / App / PrintQueue.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-03-17  |  7.9 KB  |  252 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form frmPrintQueue 
  4.    Caption         =   "Print Queue and Print Jobs"
  5.    ClientHeight    =   5700
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   7800
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   5700
  11.    ScaleWidth      =   7800
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.TextBox txtPrintStatus 
  14.       BackColor       =   &H80000004&
  15.       Height          =   285
  16.       Left            =   4200
  17.       TabIndex        =   16
  18.       Top             =   2400
  19.       Width           =   2655
  20.    End
  21.    Begin VB.TextBox txtModel 
  22.       BackColor       =   &H80000004&
  23.       Height          =   285
  24.       Left            =   4200
  25.       TabIndex        =   15
  26.       Top             =   2040
  27.       Width           =   2655
  28.    End
  29.    Begin VB.TextBox txtPrintPath 
  30.       BackColor       =   &H80000004&
  31.       Height          =   285
  32.       Left            =   4200
  33.       TabIndex        =   10
  34.       Top             =   1680
  35.       Width           =   2655
  36.    End
  37.    Begin VB.TextBox txtLocation 
  38.       BackColor       =   &H80000004&
  39.       Height          =   285
  40.       Left            =   4200
  41.       TabIndex        =   9
  42.       Top             =   1320
  43.       Width           =   2655
  44.    End
  45.    Begin VB.TextBox txtDescription 
  46.       BackColor       =   &H80000004&
  47.       Height          =   285
  48.       Left            =   4200
  49.       TabIndex        =   8
  50.       Top             =   960
  51.       Width           =   2655
  52.    End
  53.    Begin VB.CommandButton cmdRefresh 
  54.       Caption         =   "Refresh Status"
  55.       Height          =   375
  56.       Left            =   5280
  57.       TabIndex        =   7
  58.       Top             =   240
  59.       Width           =   1575
  60.    End
  61.    Begin VB.CommandButton cmdChange 
  62.       Caption         =   "Change..."
  63.       Height          =   345
  64.       Left            =   3570
  65.       TabIndex        =   2
  66.       Top             =   240
  67.       Width           =   1365
  68.    End
  69.    Begin VB.TextBox txtComputer 
  70.       BackColor       =   &H8000000F&
  71.       ForeColor       =   &H80000012&
  72.       Height          =   315
  73.       Left            =   1155
  74.       TabIndex        =   1
  75.       Top             =   255
  76.       Width           =   2265
  77.    End
  78.    Begin VB.ListBox lstPrintQueue 
  79.       Height          =   4155
  80.       Left            =   225
  81.       TabIndex        =   0
  82.       Top             =   1065
  83.       Width           =   2130
  84.    End
  85.    Begin VB.Frame Frame1 
  86.       Caption         =   "Print Jobs"
  87.       Height          =   2865
  88.       Left            =   2520
  89.       TabIndex        =   4
  90.       Top             =   2760
  91.       Width           =   5175
  92.       Begin MSComctlLib.ListView lstPrintJob 
  93.          Height          =   2415
  94.          Left            =   240
  95.          TabIndex        =   18
  96.          Top             =   240
  97.          Width           =   4815
  98.          _ExtentX        =   8493
  99.          _ExtentY        =   4260
  100.          LabelWrap       =   -1  'True
  101.          HideSelection   =   -1  'True
  102.          _Version        =   393217
  103.          ForeColor       =   -2147483640
  104.          BackColor       =   -2147483643
  105.          BorderStyle     =   1
  106.          Appearance      =   1
  107.          NumItems        =   0
  108.       End
  109.    End
  110.    Begin VB.Frame Frame3 
  111.       Caption         =   "Computer "
  112.       Height          =   735
  113.       Left            =   195
  114.       TabIndex        =   5
  115.       Top             =   15
  116.       Width           =   4920
  117.       Begin VB.Label Label1 
  118.          Caption         =   "Name:"
  119.          Height          =   270
  120.          Left            =   255
  121.          TabIndex        =   6
  122.          Top             =   270
  123.          Width           =   750
  124.       End
  125.    End
  126.    Begin VB.Label Label6 
  127.       Caption         =   "Print Status"
  128.       Height          =   255
  129.       Left            =   2640
  130.       TabIndex        =   17
  131.       Top             =   2400
  132.       Width           =   975
  133.    End
  134.    Begin VB.Label Label5 
  135.       Caption         =   "Model"
  136.       Height          =   255
  137.       Left            =   2640
  138.       TabIndex        =   14
  139.       Top             =   2040
  140.       Width           =   975
  141.    End
  142.    Begin VB.Label Label4 
  143.       Caption         =   "Printer Path"
  144.       Height          =   255
  145.       Left            =   2640
  146.       TabIndex        =   13
  147.       Top             =   1680
  148.       Width           =   1335
  149.    End
  150.    Begin VB.Label Label3 
  151.       Caption         =   "Location"
  152.       Height          =   255
  153.       Left            =   2640
  154.       TabIndex        =   12
  155.       Top             =   1320
  156.       Width           =   1335
  157.    End
  158.    Begin VB.Label lblText 
  159.       Caption         =   "Description"
  160.       Height          =   255
  161.       Left            =   2640
  162.       TabIndex        =   11
  163.       Top             =   960
  164.       Width           =   1335
  165.    End
  166.    Begin VB.Label Label2 
  167.       Caption         =   "Print Queue:"
  168.       Height          =   240
  169.       Left            =   285
  170.       TabIndex        =   3
  171.       Top             =   780
  172.       Width           =   1275
  173.    End
  174. Attribute VB_Name = "frmPrintQueue"
  175. Attribute VB_GlobalNameSpace = False
  176. Attribute VB_Creatable = False
  177. Attribute VB_PredeclaredId = True
  178. Attribute VB_Exposed = False
  179. '----------------------------------------------------------------------------
  180. '  Microsoft Active Directory 2.5 Sample Code
  181. '  Copyright (C) Microsoft Corporation, 1996 - 1999
  182. '  File: frmPrintQueue.frm
  183. '  Contents: Display PrintQueue's and Print Job's Properties for a given computer.
  184. '----------------------------------------------------------------------------
  185. '--- Variable Constants--------------
  186. Dim cont As IADsContainer
  187. Private Sub cmdChange_Click()
  188.   ShowComputerDlg
  189.   PopulateService (txtComputer)
  190. End Sub
  191. Private Sub ShowComputerDlg()
  192.   frmConnect.Show vbModal, Me
  193.   If (frmConnect.Tag = "") Then
  194.     txtComputer = "LocalHost"
  195.  Else
  196.     txtComputer = frmConnect.Tag
  197.  End If
  198. End Sub
  199. Private Sub PopulateService(computerStr As String)
  200. On Error Resume Next
  201. lstPrintQueue.Clear
  202. Set cont = GetObject("WinNT://" & computerStr & ",computer")
  203. cont.Filter = Array("PrintQueue")
  204. For Each pq In cont
  205.   lstPrintQueue.AddItem pq.Name
  206. End Sub
  207. Private Function GetCurrentPrintQueue() As IADsPrintQueue
  208.  If (lstPrintQueue.Text = "") Then
  209.     Set GetCurrentPrintQueue = Nothing
  210.     Exit Function
  211.  End If
  212.  Set GetCurrentPrintQueue = cont.GetObject("printQueue", lstPrintQueue.Text)
  213. End Function
  214. Private Sub cmdRefresh_Click()
  215.   lstPrintQueue_Click
  216. End Sub
  217. Private Sub Form_Load()
  218. '---- Print Jobs
  219. lstPrintJob.ColumnHeaders.Add , , "Description"
  220. lstPrintJob.ColumnHeaders.Add , , "User"
  221. lstPrintJob.ColumnHeaders.Add , , "Printed"
  222. lstPrintJob.ColumnHeaders.Add , , "Status"
  223. '--- Set to Report View ---------------
  224. lstPrintJob.View = 3
  225. ' Call cmdChange to force the user to select computer
  226.  cmdChange_Click
  227. End Sub
  228. Private Sub lstPrintQueue_Click()
  229. Dim pq As IADsPrintQueue
  230. Dim pQOps As IADsPrintQueueOperations
  231. Dim pj As IADsPrintJob
  232. Dim pjOps As IADsPrintJobOperations
  233. Set pq = GetCurrentPrintQueue()
  234. '-------Print Queue --------------------------
  235. On Error Resume Next
  236. txtDescription = pq.Description
  237. txtPrintPath = pq.PrinterPath
  238. txtLocation = pq.Location
  239. txtModel = pq.Model
  240. '----- Print Queue Operations ---------
  241. Set pQOps = pq
  242. txtPrintStatus = GetPrintStatus(pQOps.status)
  243. '---- Print Jobs and Print Job Operations ---------------------
  244. lstPrintJob.ListItems.Clear ' Clear the user interface
  245. For Each pj In pQOps.PrintJobs
  246.    Set pjOps = pj
  247.    Set newLine = lstPrintJob.ListItems.Add(, , pj.Description)
  248.    newLine.SubItems(1) = pj.User
  249.    newLine.SubItems(2) = CStr(pjOps.PagesPrinted)
  250.    newLine.SubItems(3) = GetJobStatus(pjOps.status)
  251. End Sub
  252.