home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / nivb_src / dirvol.frm < prev    next >
Text File  |  1993-06-03  |  12KB  |  373 lines

  1. VERSION 2.00
  2. Begin Form DirVolForm 
  3.    Caption         =   "Directory Services Test (Volume APIs)"
  4.    Height          =   4830
  5.    Left            =   450
  6.    LinkTopic       =   "Form1"
  7.    ScaleHeight     =   4425
  8.    ScaleWidth      =   8295
  9.    Top             =   1110
  10.    Width           =   8415
  11.    Begin Frame Frame1 
  12.       Caption         =   "Volume Information"
  13.       Height          =   4215
  14.       Left            =   3840
  15.       TabIndex        =   5
  16.       Top             =   120
  17.       Width           =   4335
  18.       Begin Label InUseLabel 
  19.          Height          =   255
  20.          Left            =   2760
  21.          TabIndex        =   31
  22.          Top             =   3735
  23.          Width           =   1335
  24.       End
  25.       Begin Label VolRestrictLabel 
  26.          Height          =   255
  27.          Left            =   2760
  28.          TabIndex        =   30
  29.          Top             =   3420
  30.          Width           =   1335
  31.       End
  32.       Begin Label Label15 
  33.          Alignment       =   1  'Right Justify
  34.          Caption         =   "Your volume usage (blocks):"
  35.          Height          =   255
  36.          Left            =   120
  37.          TabIndex        =   29
  38.          Top             =   3720
  39.          Width           =   2535
  40.       End
  41.       Begin Label Label14 
  42.          Alignment       =   1  'Right Justify
  43.          Caption         =   "Your volume usage restrictions (blocks):"
  44.          Height          =   375
  45.          Left            =   360
  46.          TabIndex        =   28
  47.          Top             =   3240
  48.          Width           =   2295
  49.       End
  50.       Begin Label VolumeNameLabel 
  51.          Height          =   255
  52.          Left            =   2760
  53.          TabIndex        =   27
  54.          Top             =   360
  55.          Width           =   1335
  56.       End
  57.       Begin Label Label13 
  58.          Alignment       =   1  'Right Justify
  59.          Caption         =   "Name:"
  60.          Height          =   255
  61.          Left            =   1800
  62.          TabIndex        =   26
  63.          Top             =   360
  64.          Width           =   855
  65.       End
  66.       Begin Label RemovableLabel 
  67.          Height          =   255
  68.          Left            =   2760
  69.          TabIndex        =   25
  70.          Top             =   3000
  71.          Width           =   1335
  72.       End
  73.       Begin Label HashingLabel 
  74.          Height          =   255
  75.          Left            =   2760
  76.          TabIndex        =   24
  77.          Top             =   2760
  78.          Width           =   1335
  79.       End
  80.       Begin Label BlockSizeLabel 
  81.          Height          =   255
  82.          Left            =   2760
  83.          TabIndex        =   23
  84.          Top             =   2520
  85.          Width           =   1335
  86.       End
  87.       Begin Label MaxDirEntriesLabel 
  88.          Height          =   255
  89.          Left            =   2760
  90.          TabIndex        =   22
  91.          Top             =   2280
  92.          Width           =   1335
  93.       End
  94.       Begin Label AvailDirEntriesLabel 
  95.          Height          =   255
  96.          Left            =   2760
  97.          TabIndex        =   21
  98.          Top             =   2040
  99.          Width           =   1335
  100.       End
  101.       Begin Label TotalDirEntriesLabel 
  102.          Height          =   255
  103.          Left            =   2760
  104.          TabIndex        =   20
  105.          Top             =   1800
  106.          Width           =   1335
  107.       End
  108.       Begin Label DeletedBlocksLabel 
  109.          Height          =   255
  110.          Left            =   2760
  111.          TabIndex        =   19
  112.          Top             =   1515
  113.          Width           =   1335
  114.       End
  115.       Begin Label PurgableBlocksLabel 
  116.          Height          =   255
  117.          Left            =   2760
  118.          TabIndex        =   18
  119.          Top             =   1080
  120.          Width           =   1335
  121.       End
  122.       Begin Label FreeBlocksLabel 
  123.          Height          =   255
  124.          Left            =   2760
  125.          TabIndex        =   17
  126.          Top             =   840
  127.          Width           =   1335
  128.       End
  129.       Begin Label TotalBlocksLabel 
  130.          Height          =   255
  131.          Left            =   2760
  132.          TabIndex        =   16
  133.          Top             =   600
  134.          Width           =   1335
  135.       End
  136.       Begin Label Label12 
  137.          Alignment       =   1  'Right Justify
  138.          Caption         =   "Removable media:"
  139.          Height          =   255
  140.          Left            =   840
  141.          TabIndex        =   15
  142.          Top             =   3000
  143.          Width           =   1815
  144.       End
  145.       Begin Label Label11 
  146.          Alignment       =   1  'Right Justify
  147.          Caption         =   "Hashing enabled:"
  148.          Height          =   255
  149.          Left            =   840
  150.          TabIndex        =   14
  151.          Top             =   2760
  152.          Width           =   1815
  153.       End
  154.       Begin Label Label10 
  155.          Alignment       =   1  'Right Justify
  156.          Caption         =   "Block size (bytes):"
  157.          Height          =   255
  158.          Left            =   600
  159.          TabIndex        =   13
  160.          Top             =   2520
  161.          Width           =   2055
  162.       End
  163.       Begin Label Label9 
  164.          Alignment       =   1  'Right Justify
  165.          Caption         =   "Max directory entries used:"
  166.          Height          =   255
  167.          Left            =   120
  168.          TabIndex        =   12
  169.          Top             =   2280
  170.          Width           =   2535
  171.       End
  172.       Begin Label Label8 
  173.          Alignment       =   1  'Right Justify
  174.          Caption         =   "Available directory entries:"
  175.          Height          =   255
  176.          Left            =   360
  177.          TabIndex        =   11
  178.          Top             =   2040
  179.          Width           =   2295
  180.       End
  181.       Begin Label Label7 
  182.          Alignment       =   1  'Right Justify
  183.          Caption         =   "Total directory entries:"
  184.          Height          =   255
  185.          Left            =   600
  186.          TabIndex        =   10
  187.          Top             =   1800
  188.          Width           =   2055
  189.       End
  190.       Begin Label Label6 
  191.          Alignment       =   1  'Right Justify
  192.          Caption         =   "Deleted, but not yet purgable blocks:"
  193.          Height          =   375
  194.          Left            =   840
  195.          TabIndex        =   9
  196.          Top             =   1320
  197.          Width           =   1815
  198.       End
  199.       Begin Label Label5 
  200.          Alignment       =   1  'Right Justify
  201.          Caption         =   "Purgable blocks:"
  202.          Height          =   255
  203.          Left            =   1200
  204.          TabIndex        =   8
  205.          Top             =   1080
  206.          Width           =   1455
  207.       End
  208.       Begin Label Label4 
  209.          Alignment       =   1  'Right Justify
  210.          Caption         =   "Free blocks:"
  211.          Height          =   255
  212.          Left            =   1440
  213.          TabIndex        =   7
  214.          Top             =   840
  215.          Width           =   1215
  216.       End
  217.       Begin Label Label3 
  218.          Alignment       =   1  'Right Justify
  219.          Caption         =   "Total blocks:"
  220.          Height          =   255
  221.          Left            =   1320
  222.          TabIndex        =   6
  223.          Top             =   600
  224.          Width           =   1335
  225.       End
  226.    End
  227.    Begin ListBox VolumeList 
  228.       Height          =   1005
  229.       Left            =   1200
  230.       TabIndex        =   3
  231.       Top             =   960
  232.       Width           =   2415
  233.    End
  234.    Begin CommandButton OKButton 
  235.       Caption         =   "&OK"
  236.       Height          =   375
  237.       Left            =   1440
  238.       TabIndex        =   2
  239.       Top             =   3840
  240.       Width           =   855
  241.    End
  242.    Begin ComboBox ServerNameBox 
  243.       Height          =   300
  244.       Left            =   1200
  245.       Sorted          =   -1  'True
  246.       TabIndex        =   0
  247.       Text            =   "ServerNameBox"
  248.       Top             =   360
  249.       Width           =   2415
  250.    End
  251.    Begin Label Label2 
  252.       Alignment       =   1  'Right Justify
  253.       Caption         =   "Volumes:"
  254.       Height          =   255
  255.       Left            =   120
  256.       TabIndex        =   4
  257.       Top             =   960
  258.       Width           =   975
  259.    End
  260.    Begin Label Label1 
  261.       Alignment       =   1  'Right Justify
  262.       Caption         =   "File Server:"
  263.       Height          =   255
  264.       Left            =   0
  265.       TabIndex        =   1
  266.       Top             =   360
  267.       Width           =   1095
  268.    End
  269. End
  270.  
  271. Sub Form_Load ()
  272.     For connID% = 1 To 8
  273.         fileServerName$ = String$(48, 0)
  274.         If (IsConnectionIDInUse(connID%) = 1) Then
  275.             GetFileServerName connID%, fileServerName$
  276.             ServerNameBox.AddItem fileServerName$
  277.         End If
  278.     Next connID%
  279.  
  280.     'get name of default file server for combo box
  281.     fileServerName$ = GetDefaultFileServerName()
  282.     ServerNameBox.Text = fileServerName$
  283.     ServerNameBox_Click
  284. End Sub
  285.  
  286. Sub Form_Unload (Cancel As Integer)
  287.     SetPreferredConnectionID (originalPrefConnID%)
  288. End Sub
  289.  
  290. Sub OKButton_Click ()
  291.     Unload DirVolForm
  292. End Sub
  293.  
  294. Sub ServerNameBox_Click ()
  295.     VolumeList.Clear
  296.     prefServer$ = ServerNameBox.Text
  297.     
  298.     ccode% = GetConnectionID(prefServer$, connID%)
  299.     If (ccode% = SUCCESSFUL) Then
  300.         SetPreferredConnectionID (connID%)  'tell which file server to send
  301.                                             'requests to
  302.         For volume% = 0 To 31
  303.             volumeName$ = String$(16, 0)
  304.             ccode% = GetVolumeName(volume%, volumeName$)
  305.             If ((ccode% = SUCCESSFUL) And (Asc(volumeName$) <> 0)) Then
  306.                 VolumeList.AddItem Str$(volume%) + "   " + volumeName$
  307.             End If
  308.         Next volume%
  309.  
  310.         UpdateVolumeStats
  311.     Else
  312.         MsgBox "Unable to get connection ID of server " + prefServer$, MB_OK, "Error"
  313.     End If
  314.  
  315. End Sub
  316.  
  317. Sub ServerNameBox_KeyPress (KeyAscii As Integer)
  318.     If (KeyAscii = 13) Then
  319.         ServerNameBox_Click
  320.     End If
  321. End Sub
  322.  
  323. Sub UpdateVolumeStats ()
  324.     Dim volumeUsage As NWVOL_USAGE
  325.     Dim loginTime As DATE_AND_TIME
  326.  
  327.     If (VolumeList.ListIndex = -1) Then
  328.         volume% = 0
  329.     Else
  330.         volume% = Val(VolumeList.ListIndex)
  331.     End If
  332.  
  333.     connID% = GetDefaultConnectionID()
  334.     ccode% = GetVolUsage(connID%, volume%, volumeUsage)
  335.  
  336.     TotalBlocksLabel.Caption = Str$(volumeUsage.totalBlocks)
  337.     FreeBlocksLabel.Caption = Str$(volumeUsage.freeBlocks)
  338.     PurgableBlocksLabel.Caption = Str$(volumeUsage.purgableBlocks)
  339.     DeletedBlocksLabel.Caption = Str$(volumeUsage.notYetPurgableBlocks)
  340.     TotalDirEntriesLabel.Caption = Str$(volumeUsage.totalDirEntries)
  341.     AvailDirEntriesLabel.Caption = Str$(volumeUsage.availDirEntries)
  342.     MaxDirEntriesLabel.Caption = Str$(volumeUsage.maxDirEntriesUsed)
  343.     BlockSizeLabel.Caption = Str$(volumeUsage.blockSize)
  344.     If (volumeUsage.isHashing <> Chr$(0)) Then
  345.         HashingLabel.Caption = "Yes"
  346.     Else
  347.         HashingLabel.Caption = "No"
  348.     End If
  349.     If (volumeUsage.isRemovable <> Chr$(0)) Then
  350.         RemovableLabel.Caption = "Yes"
  351.     Else
  352.         RemovableLabel.Caption = "No"
  353.     End If
  354.     VolumeNameLabel.Caption = volumeUsage.volName
  355.  
  356.     'Get user's volume disk space restrictions
  357.     connNum& = GetConnectionNumber()
  358.     myName$ = String$(48, 0)
  359.     ccode% = GetConnectionInformation(connNum&, myName$, myType%, objID&, loginTime)
  360.     ccode% = GetObjectDiskRestrictions(connID%, volume%, objID&, volRestrict&, inUse&)
  361.     If (volRestrict& = &H40000000) Then
  362.         VolRestrictLabel.Caption = "None"
  363.     Else
  364.         VolRestrictLabel.Caption = Str$(volRestrict&)
  365.     End If
  366.     InUseLabel.Caption = Str$(inUse&)
  367. End Sub
  368.  
  369. Sub VolumeList_Click ()
  370.     UpdateVolumeStats
  371. End Sub
  372.  
  373.