home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / drv_util / drvdemo.frm < prev    next >
Text File  |  1994-03-06  |  14KB  |  500 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "DrvUtils.DLL Test Program"
  4.    ClientHeight    =   4788
  5.    ClientLeft      =   1008
  6.    ClientTop       =   1644
  7.    ClientWidth     =   3912
  8.    Height          =   5232
  9.    Left            =   948
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    ScaleHeight     =   4788
  13.    ScaleWidth      =   3912
  14.    Top             =   1260
  15.    Width           =   4032
  16.    Begin CommandButton Command5 
  17.       Caption         =   "ZAPP This File"
  18.       Height          =   252
  19.       Left            =   240
  20.       TabIndex        =   33
  21.       Top             =   4440
  22.       Width           =   1392
  23.    End
  24.    Begin CommandButton Command4 
  25.       Caption         =   "Exit the Demo"
  26.       Height          =   372
  27.       Left            =   1860
  28.       TabIndex        =   32
  29.       Top             =   4380
  30.       Width           =   1992
  31.    End
  32.    Begin CommandButton Command3 
  33.       Caption         =   "Set Attributes"
  34.       Height          =   252
  35.       Left            =   1860
  36.       TabIndex        =   31
  37.       Top             =   4020
  38.       Width           =   1992
  39.    End
  40.    Begin CommandButton Command1 
  41.       Caption         =   "Set Time/Date"
  42.       Height          =   252
  43.       Left            =   60
  44.       TabIndex        =   30
  45.       Top             =   4020
  46.       Width           =   1692
  47.    End
  48.    Begin CheckBox Check4 
  49.       Caption         =   "Archive"
  50.       Height          =   252
  51.       Left            =   3000
  52.       TabIndex        =   29
  53.       Top             =   3660
  54.       Width           =   1032
  55.    End
  56.    Begin CheckBox Check3 
  57.       Caption         =   "System"
  58.       Height          =   252
  59.       Left            =   3000
  60.       TabIndex        =   28
  61.       Top             =   3360
  62.       Width           =   1032
  63.    End
  64.    Begin CheckBox Check2 
  65.       Caption         =   "Hidden"
  66.       Height          =   252
  67.       Left            =   1860
  68.       TabIndex        =   27
  69.       Top             =   3660
  70.       Width           =   1152
  71.    End
  72.    Begin CheckBox Check1 
  73.       Caption         =   "Read Only"
  74.       Height          =   252
  75.       Left            =   1860
  76.       TabIndex        =   26
  77.       Top             =   3360
  78.       Width           =   1152
  79.    End
  80.    Begin TextBox Text6 
  81.       Height          =   288
  82.       Left            =   840
  83.       TabIndex        =   24
  84.       Top             =   3600
  85.       Width           =   912
  86.    End
  87.    Begin TextBox Text5 
  88.       Height          =   288
  89.       Left            =   840
  90.       TabIndex        =   23
  91.       Top             =   3300
  92.       Width           =   912
  93.    End
  94.    Begin TextBox Text4 
  95.       Height          =   288
  96.       Left            =   840
  97.       TabIndex        =   22
  98.       Top             =   3000
  99.       Width           =   912
  100.    End
  101.    Begin TextBox Text3 
  102.       Height          =   288
  103.       Left            =   840
  104.       TabIndex        =   21
  105.       Top             =   2700
  106.       Width           =   912
  107.    End
  108.    Begin TextBox Text2 
  109.       Height          =   288
  110.       Left            =   840
  111.       TabIndex        =   20
  112.       Top             =   2100
  113.       Width           =   912
  114.    End
  115.    Begin TextBox Text1 
  116.       Height          =   288
  117.       Left            =   840
  118.       TabIndex        =   19
  119.       Top             =   2400
  120.       Width           =   912
  121.    End
  122.    Begin FileListBox File1 
  123.       Height          =   1944
  124.       Left            =   1800
  125.       TabIndex        =   12
  126.       Top             =   960
  127.       Width           =   2112
  128.    End
  129.    Begin DirListBox Dir1 
  130.       Height          =   1104
  131.       Left            =   0
  132.       TabIndex        =   11
  133.       Top             =   960
  134.       Width           =   1812
  135.    End
  136.    Begin DriveListBox Drive1 
  137.       Height          =   288
  138.       Left            =   0
  139.       TabIndex        =   0
  140.       Top             =   0
  141.       Width           =   1812
  142.    End
  143.    Begin Line Line3 
  144.       X1              =   0
  145.       X2              =   3900
  146.       Y1              =   3960
  147.       Y2              =   3960
  148.    End
  149.    Begin Line Line2 
  150.       X1              =   1500
  151.       X2              =   2460
  152.       Y1              =   2220
  153.       Y2              =   2580
  154.    End
  155.    Begin Line Line1 
  156.       X1              =   0
  157.       X2              =   4020
  158.       Y1              =   900
  159.       Y2              =   900
  160.    End
  161.    Begin Label Label18 
  162.       Height          =   252
  163.       Left            =   2700
  164.       TabIndex        =   34
  165.       Top             =   3000
  166.       Width           =   1152
  167.    End
  168.    Begin Label Label17 
  169.       Caption         =   "Size"
  170.       Height          =   252
  171.       Left            =   1860
  172.       TabIndex        =   25
  173.       Top             =   3000
  174.       Width           =   792
  175.    End
  176.    Begin Label Label16 
  177.       Caption         =   "Second"
  178.       Height          =   252
  179.       Left            =   60
  180.       TabIndex        =   18
  181.       Top             =   3600
  182.       Width           =   732
  183.    End
  184.    Begin Label Label15 
  185.       Caption         =   "Minute"
  186.       Height          =   252
  187.       Left            =   60
  188.       TabIndex        =   17
  189.       Top             =   3300
  190.       Width           =   732
  191.    End
  192.    Begin Label Label14 
  193.       Caption         =   "Hour"
  194.       Height          =   252
  195.       Left            =   60
  196.       TabIndex        =   16
  197.       Top             =   3000
  198.       Width           =   732
  199.    End
  200.    Begin Label Label13 
  201.       Caption         =   "Year"
  202.       Height          =   252
  203.       Left            =   60
  204.       TabIndex        =   15
  205.       Top             =   2700
  206.       Width           =   732
  207.    End
  208.    Begin Label Label12 
  209.       Caption         =   "Month"
  210.       Height          =   252
  211.       Left            =   60
  212.       TabIndex        =   14
  213.       Top             =   2100
  214.       Width           =   732
  215.    End
  216.    Begin Label Label11 
  217.       Caption         =   "Day"
  218.       Height          =   252
  219.       Left            =   60
  220.       TabIndex        =   13
  221.       Top             =   2400
  222.       Width           =   732
  223.    End
  224.    Begin Label Label10 
  225.       Height          =   252
  226.       Left            =   900
  227.       TabIndex        =   10
  228.       Top             =   600
  229.       Width           =   852
  230.    End
  231.    Begin Label Label9 
  232.       Height          =   252
  233.       Left            =   900
  234.       TabIndex        =   9
  235.       Top             =   300
  236.       Width           =   852
  237.    End
  238.    Begin Label Label8 
  239.       Height          =   252
  240.       Left            =   2580
  241.       TabIndex        =   8
  242.       Top             =   600
  243.       Width           =   1272
  244.    End
  245.    Begin Label Label7 
  246.       Height          =   252
  247.       Left            =   2580
  248.       TabIndex        =   7
  249.       Top             =   300
  250.       Width           =   1272
  251.    End
  252.    Begin Label Label6 
  253.       Height          =   252
  254.       Left            =   2580
  255.       TabIndex        =   6
  256.       Top             =   0
  257.       Width           =   1272
  258.    End
  259.    Begin Label Label5 
  260.       Caption         =   "Cluster"
  261.       Height          =   252
  262.       Left            =   60
  263.       TabIndex        =   5
  264.       Top             =   600
  265.       Width           =   792
  266.    End
  267.    Begin Label Label4 
  268.       Caption         =   "Sector"
  269.       Height          =   252
  270.       Left            =   60
  271.       TabIndex        =   4
  272.       Top             =   300
  273.       Width           =   792
  274.    End
  275.    Begin Label Label3 
  276.       Caption         =   "Free"
  277.       Height          =   252
  278.       Left            =   1860
  279.       TabIndex        =   3
  280.       Top             =   600
  281.       Width           =   552
  282.    End
  283.    Begin Label Label2 
  284.       Caption         =   "Used"
  285.       Height          =   252
  286.       Left            =   1860
  287.       TabIndex        =   2
  288.       Top             =   300
  289.       Width           =   552
  290.    End
  291.    Begin Label Label1 
  292.       Caption         =   "Size"
  293.       Height          =   252
  294.       Left            =   1860
  295.       TabIndex        =   1
  296.       Top             =   0
  297.       Width           =   552
  298.    End
  299. End
  300. Option Explicit
  301.  
  302. Sub Command1_Click ()
  303.     Dim Stat As Integer
  304.     Dim Ayear As Integer
  305.     Dim Amonth As Integer
  306.     Dim Aday As Integer
  307.     Dim Ahour As Integer
  308.     Dim Aminute As Integer
  309.     Dim Asecond As Integer
  310.     Dim FName As String
  311.     'Build the full file name
  312.     If (Right$(File1.Path, 1) = "\") Then
  313.         FName = File1.Path + File1.FileName
  314.     Else
  315.         FName = File1.Path + "\" + File1.FileName
  316.     End If
  317.     'Collect the user's new date/time stamp
  318.     Aday = Val(Text1.Text)
  319.     Amonth = Val(Text2.Text)
  320.     Ayear = Val(Text3.Text)
  321.     Ahour = Val(Text4.Text)
  322.     Aminute = Val(Text5.Text)
  323.     Asecond = Val(Text6.Text)
  324.     Stat = MsgBox("Are you sure you want to change date/time?", 4)
  325.     If (Stat = 6) Then
  326.         'Call the Drive Utilities DLL routine
  327.         Stat = FileSetDateTime(FName, Ayear, Amonth, Aday, Ahour, Aminute, Asecond)
  328.         File1_DblClick
  329.     End If
  330. End Sub
  331.  
  332. Sub Command3_Click ()
  333.     Dim Stat As Integer
  334.     Dim Attribute As Integer
  335.     Dim FName As String
  336.     'Build the full file name
  337.     If (Right$(File1.Path, 1) = "\") Then
  338.         FName = File1.Path + File1.FileName
  339.     Else
  340.         FName = File1.Path + "\" + File1.FileName
  341.     End If
  342.     'Turn on attribute bits based on check boxes
  343.     Attribute = 0
  344.     If (Check1.Value = 1) Then
  345.         Attribute = Attribute + A_RDONLY
  346.     End If
  347.     If (Check2.Value = 1) Then
  348.         Attribute = Attribute + A_HIDDEN
  349.     End If
  350.     If (Check3.Value = 1) Then
  351.         Attribute = Attribute + A_SYSTEM
  352.     End If
  353.     If (Check4.Value = 1) Then
  354.         Attribute = Attribute + A_ARCH
  355.     End If
  356.     Stat = MsgBox("Are you sure you want to change attributes?", 4)
  357.     If (Stat = 6) Then
  358.         'Call the Drive Utilities DLL routine
  359.         Stat = FileSetAttributes(FName, Attribute)
  360.         File1_DblClick
  361.     End If
  362. End Sub
  363.  
  364. Sub Command4_Click ()
  365.     End
  366. End Sub
  367.  
  368. Sub Command5_Click ()
  369.     Dim Stat As Integer
  370.     Dim FName As String
  371.     'Build the full file name
  372.     If (Right$(File1.Path, 1) = "\") Then
  373.         FName = File1.Path + File1.FileName
  374.     Else
  375.         FName = File1.Path + "\" + File1.FileName
  376.     End If
  377.     'Make sure they REALLY want to zapp the file
  378.     Stat = MsgBox("Are you sure you want to ZAPP this file?", 4)
  379.     If (Stat = 6) Then
  380.         Stat = MsgBox("This will COMPLETELY KILL this file!  Continue?", 4)
  381.         If (Stat = 6) Then
  382.             'Call the Drive Utilities DLL routine
  383.             Stat = FileZAPP(FName, 0)
  384.             File1.Refresh
  385.             File1_DblClick
  386.         End If
  387.     End If
  388. End Sub
  389.  
  390. Sub Dir1_Change ()
  391.     If (Right$(Dir1.Path, 1) = "\") Then
  392.         File1.FileName = Dir1.Path + "*.*"
  393.     Else
  394.         File1.FileName = Dir1.Path + "\*.*"
  395.     End If
  396. End Sub
  397.  
  398. Sub Drive1_Change ()
  399.     Dim Drv As String
  400.     Dim BTotal As Long
  401.     Dim BUsed As Long
  402.     Dim BFree As Long
  403.     Dim BSector As Long
  404.     Dim BCluster As Long
  405.     'Get the drive, to pass to DRVUTILS.DLL
  406.     Drv = Drive1.Drive
  407.     Dir1.Path = Drv + "\"
  408.     'Now, get all of the information
  409.     BTotal = DiskBytesTotal(Drv)
  410.     BUsed = DiskBytesUsed(Drv)
  411.     BFree = DiskBytesFree(Drv)
  412.     BSector = DiskBytesSector(Drv)
  413.     BCluster = DiskBytesCluster(Drv)
  414.     'Now put information on form
  415.     Label6.Caption = Format$(BTotal, "#,##0")
  416.     Label7.Caption = Format$(BUsed, "#,##0")
  417.     Label8.Caption = Format$(BFree, "#,##0")
  418.     Label9.Caption = Format$(BSector, "#,##0")
  419.     Label10.Caption = Format$(BCluster, "#,##0")
  420. End Sub
  421.  
  422. Sub File1_DblClick ()
  423.     Dim Stat As Integer
  424.     Dim FName As String
  425.     Dim FSiz As Long
  426.     Dim FAttr As Integer
  427.  
  428.     Dim Ayear As Integer
  429.     Dim Amonth As Integer
  430.     Dim Aday As Integer
  431.     Dim Ahour As Integer
  432.     Dim Aminute As Integer
  433.     Dim Asecond As Integer
  434.  
  435.     'Build the full file name
  436.     If (Right$(File1.Path, 1) = "\") Then
  437.         FName = File1.Path + File1.FileName
  438.     Else
  439.         FName = File1.Path + "\" + File1.FileName
  440.     End If
  441.     'Now call the Get routines
  442.     Stat = FileGetDateTime(FName, Ayear, Amonth, Aday, Ahour, Aminute, Asecond)
  443.     FSiz = FileGetBytes(FName)
  444.     FAttr = FileGetAttributes(FName)
  445.     'Now display the results
  446.     Text1.Text = Str$(Aday)
  447.     Text2.Text = Str$(Amonth)
  448.     Text3.Text = Str$(Ayear)
  449.     Text4.Text = Str$(Ahour)
  450.     Text5.Text = Str$(Aminute)
  451.     Text6.Text = Str$(Asecond)
  452.     Label18.Caption = Str$(FSiz)
  453.     'Extract attribute information
  454.     'See if file is read only
  455.     If (FAttr And A_RDONLY) Then
  456.         Check1.Value = 1
  457.     Else
  458.         Check1.Value = 0
  459.     End If
  460.     'See if file is hidden
  461.     If (FAttr And A_HIDDEN) Then
  462.         Check2.Value = 1
  463.     Else
  464.         Check2.Value = 0
  465.     End If
  466.     'See if file is a system file
  467.     If (FAttr And A_SYSTEM) Then
  468.         Check3.Value = 1
  469.     Else
  470.         Check3.Value = 0
  471.     End If
  472.     'See if archive bit is set
  473.     If (FAttr And A_ARCH) Then
  474.         Check4.Value = 1
  475.     Else
  476.         Check4.Value = 0
  477.     End If
  478. End Sub
  479.  
  480. Sub Form_Load ()
  481.     Dim BTotal As Long
  482.     Dim BUsed As Long
  483.     Dim BFree As Long
  484.     Dim BSector As Long
  485.     Dim BCluster As Long
  486.     'Now, get all of the information
  487.     BTotal = DiskBytesTotal("")
  488.     BUsed = DiskBytesUsed("")
  489.     BFree = DiskBytesFree("")
  490.     BSector = DiskBytesSector("")
  491.     BCluster = DiskBytesCluster("")
  492.     'Now put information on form
  493.     Label6.Caption = Format$(BTotal, "#,##0")
  494.     Label7.Caption = Format$(BUsed, "#,##0")
  495.     Label8.Caption = Format$(BFree, "#,##0")
  496.     Label9.Caption = Format$(BSector, "#,##0")
  497.     Label10.Caption = Format$(BCluster, "#,##0")
  498. End Sub
  499.  
  500.