home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / code / network / vbnets / vb-nets.frm < prev    next >
Text File  |  1994-10-11  |  14KB  |  378 lines

  1. VERSION 2.00
  2. Begin Form frmVBNets 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "VB-Nets Sample"
  5.    ClientHeight    =   3450
  6.    ClientLeft      =   1335
  7.    ClientTop       =   1950
  8.    ClientWidth     =   6510
  9.    Height          =   4140
  10.    Icon            =   VB-NETS.FRX:0000
  11.    Left            =   1275
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   3450
  14.    ScaleWidth      =   6510
  15.    Top             =   1320
  16.    Width           =   6630
  17.    Begin CommandButton cmdSel 
  18.       BackColor       =   &H00C0C0C0&
  19.       Caption         =   "&Find Drive"
  20.       Height          =   345
  21.       Index           =   3
  22.       Left            =   4830
  23.       TabIndex        =   14
  24.       Top             =   1590
  25.       Width           =   1515
  26.    End
  27.    Begin CommandButton cmdSel 
  28.       BackColor       =   &H00C0C0C0&
  29.       Caption         =   "Find &Service"
  30.       Height          =   345
  31.       Index           =   2
  32.       Left            =   4830
  33.       TabIndex        =   13
  34.       Top             =   1200
  35.       Width           =   1515
  36.    End
  37.    Begin CommandButton cmdSel 
  38.       BackColor       =   &H00C0C0C0&
  39.       Caption         =   "&Dismount"
  40.       Height          =   345
  41.       Index           =   1
  42.       Left            =   4830
  43.       TabIndex        =   12
  44.       Top             =   810
  45.       Width           =   1515
  46.    End
  47.    Begin CommandButton cmdSel 
  48.       BackColor       =   &H00C0C0C0&
  49.       Caption         =   "&Mount"
  50.       Height          =   345
  51.       Index           =   0
  52.       Left            =   4830
  53.       TabIndex        =   11
  54.       Top             =   420
  55.       Width           =   1515
  56.    End
  57.    Begin TextBox txtService 
  58.       Height          =   285
  59.       Index           =   3
  60.       Left            =   1380
  61.       TabIndex        =   6
  62.       Top             =   1410
  63.       Width           =   3045
  64.    End
  65.    Begin TextBox txtService 
  66.       Height          =   285
  67.       Index           =   2
  68.       Left            =   1380
  69.       TabIndex        =   5
  70.       Top             =   1080
  71.       Width           =   3045
  72.    End
  73.    Begin TextBox txtService 
  74.       Height          =   285
  75.       Index           =   1
  76.       Left            =   1380
  77.       TabIndex        =   4
  78.       Top             =   750
  79.       Width           =   3045
  80.    End
  81.    Begin TextBox txtService 
  82.       Height          =   285
  83.       Index           =   0
  84.       Left            =   1380
  85.       TabIndex        =   3
  86.       Top             =   420
  87.       Width           =   3045
  88.    End
  89.    Begin ListBox lstServices 
  90.       Height          =   1200
  91.       Left            =   150
  92.       TabIndex        =   0
  93.       TabStop         =   0   'False
  94.       Top             =   2160
  95.       Width           =   6195
  96.    End
  97.    Begin Label lblInstructions 
  98.       BackColor       =   &H00C0C0C0&
  99.       Caption         =   "Check 'Help' for instructions on using the service buttons ..."
  100.       Height          =   225
  101.       Left            =   540
  102.       TabIndex        =   2
  103.       Top             =   90
  104.       Width           =   5415
  105.    End
  106.    Begin Label lblService 
  107.       BackColor       =   &H00C0C0C0&
  108.       Caption         =   "Password:"
  109.       Height          =   195
  110.       Index           =   3
  111.       Left            =   180
  112.       TabIndex        =   10
  113.       Top             =   1470
  114.       Width           =   1095
  115.    End
  116.    Begin Label lblService 
  117.       BackColor       =   &H00C0C0C0&
  118.       Caption         =   "Service:"
  119.       Height          =   195
  120.       Index           =   2
  121.       Left            =   180
  122.       TabIndex        =   9
  123.       Top             =   1140
  124.       Width           =   1095
  125.    End
  126.    Begin Label lblService 
  127.       BackColor       =   &H00C0C0C0&
  128.       Caption         =   "Server:"
  129.       Height          =   195
  130.       Index           =   1
  131.       Left            =   180
  132.       TabIndex        =   8
  133.       Top             =   810
  134.       Width           =   1095
  135.    End
  136.    Begin Label lblService 
  137.       BackColor       =   &H00C0C0C0&
  138.       Caption         =   "Drive:"
  139.       Height          =   195
  140.       Index           =   0
  141.       Left            =   180
  142.       TabIndex        =   7
  143.       Top             =   480
  144.       Width           =   1095
  145.    End
  146.    Begin Label lblServiceList 
  147.       BackColor       =   &H00C0C0C0&
  148.       Caption         =   "Mounted Network Services:"
  149.       Height          =   225
  150.       Left            =   180
  151.       TabIndex        =   1
  152.       Top             =   1890
  153.       Width           =   2895
  154.    End
  155.    Begin Menu mnuFile 
  156.       Caption         =   "&File"
  157.       Begin Menu mnuFileSel 
  158.          Caption         =   "Network &User"
  159.          Index           =   0
  160.       End
  161.       Begin Menu mnuFileSel 
  162.          Caption         =   "Network &Type"
  163.          Index           =   1
  164.       End
  165.       Begin Menu mnuFileSel 
  166.          Caption         =   "-"
  167.          Index           =   2
  168.       End
  169.       Begin Menu mnuFileSel 
  170.          Caption         =   "E&xit"
  171.          Index           =   3
  172.       End
  173.    End
  174.    Begin Menu mnuHelp 
  175.       Caption         =   "&Help"
  176.       Begin Menu mnuHelpSel 
  177.          Caption         =   "Using 'Mount"""
  178.          Index           =   0
  179.       End
  180.       Begin Menu mnuHelpSel 
  181.          Caption         =   "Using 'Dismount'"
  182.          Index           =   1
  183.       End
  184.       Begin Menu mnuHelpSel 
  185.          Caption         =   "Using 'Find Service'"
  186.          Index           =   2
  187.       End
  188.       Begin Menu mnuHelpSel 
  189.          Caption         =   "Using 'Find Drive'"
  190.          Index           =   3
  191.       End
  192.       Begin Menu mnuHelpSel 
  193.          Caption         =   "-"
  194.          Index           =   4
  195.       End
  196.       Begin Menu mnuHelpSel 
  197.          Caption         =   "&About"
  198.          Index           =   5
  199.       End
  200.    End
  201. End
  202. Option Explicit
  203.  
  204. ' Copyright ⌐ 1994 by Computer Technologies, Inc. All rights reserved.
  205.  
  206. Dim ftCRLF           As String
  207.  
  208. Sub APP_ListServices ()
  209.  
  210. ' Copyright ⌐ 1994 by Computer Technologies, Inc. All rights reserved.
  211.  
  212.     Dim nLoopCtr            As Integer
  213.     Dim tTempStr            As String
  214.  
  215. ' Hide the list box to avoid flashing
  216.     lstServices.Visible = False
  217.  
  218. ' Clear the list box of all current entries
  219.     Do While lstServices.ListCount > 0
  220.         lstServices.RemoveItem 0
  221.     Loop
  222.  
  223. ' Load the list box with all mounted services
  224.     For nLoopCtr = 4 To 26          ' For drives D: to Z:
  225.         tTempStr = UT_NetGetServiceName(Chr$(64 + nLoopCtr))
  226.         If Len(tTempStr) > 0 Then   ' The drive is mounted
  227.             lstServices.AddItem Chr$(64 + nLoopCtr) & ":" & Chr$(9) & tTempStr
  228.         End If
  229.     Next nLoopCtr
  230.  
  231. ' Now that we are done we can show the list box
  232.     lstServices.Visible = True
  233.  
  234. End Sub
  235.  
  236. Sub cmdSel_Click (Index As Integer)
  237.  
  238. ' Copyright ⌐ 1994 by Computer Technologies, Inc. All rights reserved.
  239.     
  240.     Dim tTempStr            As String
  241.     Dim tService            As String
  242.     Dim nResult             As Integer
  243.     Dim nLoopCtr            As Integer
  244.  
  245.     Select Case Index
  246.         Case 0              ' Mount
  247.             If Len((txtService(0))) = 0 Or Len((txtService(1))) = 0 Or Len((txtService(2))) = 0 Then
  248.                 Call mnuHelpSel_Click(Index)        ' Call help because there are missing parameters
  249.                 Exit Sub
  250.             End If
  251.             tTempStr = UT_NetMount((txtService(0)), (txtService(1)), (txtService(2)), (txtService(3)))
  252.             If Len(tTempStr) <> 0 Then
  253.                 MsgBox "Service mounted", MB_ICONINFORMATION, "Drive " & UCase$(Left$((txtService(0)), 1)) & ":"
  254.                 Call APP_ListServices               ' Refresh the services list
  255.               Else
  256.                 tService = "\\" & (txtService(1)) & "\" & (txtService(2))
  257.                 MsgBox "Service NOT mounted", MB_ICONEXCLAMATION, "Service: " & tService
  258.             End If
  259.         
  260.         Case 1              ' Dismount
  261.             If Len((txtService(0))) = 0 Then
  262.                 Call mnuHelpSel_Click(Index)        ' Call help because there are missing parameters
  263.                 Exit Sub
  264.             End If
  265.             nResult = UT_NetDismount((txtService(0)), NET_OPENQUERY)
  266.             If nResult = True Then
  267.                 MsgBox "Service dismounted", MB_ICONINFORMATION, "Drive " & UCase$(Left$((txtService(0)), 1)) & ":"
  268.                 Call APP_ListServices               ' Refresh the services list
  269.               Else
  270.                 MsgBox "Service NOT dismounted", MB_ICONEXCLAMATION, "Drive " & UCase$(Left$((txtService(0)), 1)) & ":"
  271.             End If
  272.         
  273.         Case 2              ' Find Service
  274.             If Len((txtService(0))) = 0 Then
  275.                 Call mnuHelpSel_Click(Index)        ' Call help because there are missing parameters
  276.                 Exit Sub
  277.             End If
  278.             tTempStr = UT_NetGetServiceName((txtService(0)))            ' Get the service name
  279.             If Len(tTempStr) <> 0 Then
  280.                 MsgBox "Service Name: " & tTempStr, MB_ICONINFORMATION, "Drive " & UCase$(Left$((txtService(0)), 1)) & ":"
  281.               Else
  282.                 MsgBox "There is no service connected to this drive.", MB_ICONSTOP, "Drive " & UCase$(Left$((txtService(0)), 1)) & ":"
  283.             End If
  284.         
  285.         Case 3              ' Find Drive
  286.             If Len((txtService(1))) = 0 Or Len((txtService(2))) = 0 Then
  287.                 Call mnuHelpSel_Click(Index)        ' Call help because there are missing parameters
  288.                 Exit Sub
  289.             End If
  290.             tService = "\\" & (txtService(1)) & "\" & (txtService(2))   ' Build the service name we are looking for
  291.             tTempStr = UT_NetGetServiceDrive(tService)                  ' Find the drive letter
  292.             If Len(tTempStr) <> 0 Then
  293.                 MsgBox "Service is connected to drive " & UCase$(tTempStr), MB_ICONINFORMATION, "Service: " & tService
  294.               Else
  295.                 MsgBox "This service is not mounted or connected to a local drive.", MB_ICONSTOP, "Service: " & tService
  296.             End If
  297.     
  298.     End Select
  299.  
  300. End Sub
  301.  
  302. Sub Form_Load ()
  303.  
  304. ' Copyright ⌐ 1994 by Computer Technologies, Inc. All rights reserved.
  305.  
  306.     Dim tTempStr            As String
  307.     
  308. ' Center the form on the screen
  309.     UT_CenterScreen Me
  310.  
  311. ' Setup form scope globals
  312.     ftCRLF = Chr$(13) & Chr$(10)
  313.  
  314. ' Load the services list box
  315.     Call APP_ListServices
  316.  
  317. ' Popup the About box dialog
  318.     Call mnuHelpSel_Click(5)
  319.  
  320. End Sub
  321.  
  322. Sub mnuFileSel_Click (Index As Integer)
  323.  
  324. ' Copyright ⌐ 1994 by Computer Technologies, Inc. All rights reserved.
  325.  
  326.     Dim tTempStr            As String
  327.     
  328.     Select Case Index
  329.         Case 0                  ' Network User
  330.             tTempStr = UT_NetUserID()
  331.             If Len(tTempStr) = 0 Then           ' Not logged in
  332.                 MsgBox "The user is not logged in to the network. It is also possible that this is a Windows for Workgroups machine using multiple network protocols. If Workgroups is not the first protocol, the user name may not be reported correctly.", MB_ICONINFORMATION, "Network User"
  333.               Else                              ' User is logged in
  334.                 MsgBox "Logged in to the network as: " & Trim$(tTempStr), MB_ICONINFORMATION, "Network User"
  335.             End If
  336.             
  337.         Case 1                  ' Network Type
  338.             tTempStr = UT_GetNetworkType()
  339.             If Len(tTempStr) = 0 Then           ' Unknown network type
  340.                 MsgBox "Unable to determine the network type for this system.", MB_ICONINFORMATION, "Network Type"
  341.               Else
  342.                 MsgBox "The current network is " & Trim$(tTempStr), MB_ICONINFORMATION, "Network Type"
  343.             End If
  344.         Case 3                  ' Exit
  345.             Unload frmVBNets
  346.             End
  347.     End Select
  348.  
  349. End Sub
  350.  
  351. Sub mnuHelpSel_Click (Index As Integer)
  352.  
  353. ' Copyright ⌐ 1994 by Computer Technologies, Inc. All rights reserved.
  354.  
  355.     Dim tTempStr            As String
  356.  
  357.     Select Case Index
  358.         Case 0              ' Mount
  359.             MsgBox "The mount option requires a drive letter, a server name, and a service. The password is optional.", MB_ICONINFORMATION, "Using 'Mount'"
  360.         Case 1              ' Dismount
  361.             MsgBox "The dismount option requires a drive letter.", MB_ICONINFORMATION, "Using 'Dismount'"
  362.         Case 2              ' Find Service
  363.             MsgBox "The find service option requires a drive letter.", MB_ICONINFORMATION, "Using 'Find Service'"
  364.         Case 3              ' Find Drive
  365.             MsgBox "The find drive option requires a server name and a service.", MB_ICONINFORMATION, "Using 'Find Drive'"
  366.         Case 5              ' About
  367.             tTempStr = "Copyright ⌐ 1994 by Computer Technologies, Inc." & ftCRLF & "All rights reserved."
  368.             tTempStr = tTempStr & ftCRLF & ftCRLF & "Version 1.1 - Released October 11, 1994."
  369.             tTempStr = tTempStr & ftCRLF & ftCRLF & "This demo program and the associated code in CTI-NETS.BAS are the property of Computer Technologies, Inc. It is provided as a service for the personal use of the members of the MS-BASIC forum on CompuServe, and other interested Visual Basic developers."
  370.             tTempStr = tTempStr & ftCRLF & ftCRLF & "Author:" & Chr$(9) & "Eric Brierley"
  371.             tTempStr = tTempStr & ftCRLF & "CIS:" & Chr$(9) & "71163,2657"
  372.             tTempStr = tTempStr & ftCRLF & "Phone:" & Chr$(9) & "1-704-634-1766"
  373.             MsgBox tTempStr, MB_ICONINFORMATION, "About VB-NETS"
  374.     End Select
  375.  
  376. End Sub
  377.  
  378.