home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / IPXSPX.ZIP / CLIENT.TXT < prev    next >
Text File  |  1993-12-20  |  8KB  |  310 lines

  1. Option Explicit
  2. Option Base 1
  3.  
  4. Sub About_Click ()
  5.     aboutForm.Show 1
  6. End Sub
  7.  
  8. Sub BinderyObjList_DblCLick ()
  9.     Dim Address As String
  10.     Dim formatString As String
  11.     Dim nwTime As String
  12.     Dim YY, MM, DD, HR, MI, SC, DA As Integer
  13.     Dim nwLoginTime  As Variant
  14.     Dim nwUser As USER_INFO
  15.     Dim ccode, index As Integer
  16.  
  17.     nwUser = netWareUsers(BinderyObjList.ListIndex + 1)
  18.     userName = Mid$(BinderyObjList.Text, 1, 20)
  19.     userConn = nwUser.connNumber
  20.     nwTime = nwUser.loginTime
  21.     YY = Asc(Mid(nwTime, 1, 1)) + 1900
  22.     MM = Asc(Mid(nwTime, 2, 1))
  23.     DD = Asc(Mid(nwTime, 3, 1))
  24.     HR = Asc(Mid(nwTime, 4, 1))
  25.     MI = Asc(Mid(nwTime, 5, 1))
  26.     SC = Asc(Mid(nwTime, 6, 1))
  27.     
  28.     'pretty print the login time
  29.     nwLoginTime = DateSerial(YY, MM, DD)
  30.     formatString = Format$(nwLoginTime, "mm-dd-yyyy")
  31.     userLoginTime = formatString
  32.  
  33.     'pretty print the login date
  34.     formatString = TimeSerial(HR, MI, SC)
  35.     userLoginDay = formatString
  36.     
  37.     'pretty print the internet address
  38.     ccode = NWGetInternetAddress(nwConn, userConn, yourInetAddress)
  39.     If ccode Then
  40.     MsgBox "Error getting internet addresss"
  41.     End If
  42.  
  43.     formatString = yourInetAddress.network & yourInetAddress.node
  44.     FormatInternetAddress formatString
  45.     
  46.     userAddress = formatString
  47.     userPicture.Visible = True
  48.     
  49.     Rem The following sets up the remote name, the network, node and socket (&h5454)
  50.     spx1.RemoteName = yourInetAddress.network & yourInetAddress.node & Chr$(&H54) & Chr$(&H54)
  51.     connectButton.SetFocus
  52.  
  53. End Sub
  54.  
  55. Sub BinderyObjList_KeyPress (KeyAscii As Integer)
  56.     If KeyAscii = 13 Then
  57.     BinderyObjList_DblCLick
  58.     End If
  59. End Sub
  60.  
  61. Sub cancelButton_Click ()
  62.     
  63.     spx1.Status = 0
  64.     userPicture.Visible = False
  65.     receiveList.Visible = False
  66.     connectButton.Enabled = True
  67.     disConnectButton.Enabled = False
  68.  
  69. End Sub
  70.  
  71. Sub connectButton_Click ()
  72.     
  73.     If Mid$(spx1.LocalName, 1, 10) = Mid$(spx1.RemoteName, 1, 10) Then
  74.     MsgBox "Unable to directory to yourself"
  75.     Exit Sub
  76.     End If
  77.     
  78.     receiveList.Clear
  79.     spx1.Send = "DIR"
  80.     
  81. End Sub
  82.  
  83. Sub disconnectButton_Click ()
  84.     
  85.     spx1.Status = 0
  86.  
  87.     userPicture.Visible = False
  88.     receiveList.Visible = False
  89.     connectButton.Enabled = True
  90.     disConnectButton.Enabled = False
  91.     cancelButton.Enabled = True
  92.  
  93. End Sub
  94.  
  95. Sub exitButton_Click ()
  96.     End
  97. End Sub
  98.  
  99. Sub Form_Load ()
  100.     Dim title, server, fileServerName As String
  101.     Dim ccode, connID As Integer
  102.     Dim s As String
  103.  
  104.     ccode = NWCallsInit(ByVal 0&, ByVal 0&)
  105.     If ccode Then
  106.     MsgBox "Unable to initialize NWCALLS.DLL"
  107.     End
  108.     End If
  109.  
  110.     spx1.LinkType = 1  'REM This is the default anyway
  111.  
  112.     Screen.MousePointer = 11        'change mouse cursor to hourglass
  113.  
  114.     server = String$(48, 0)
  115.     server = GetConnections()
  116.  
  117.     ScanUsers server    'scan the bindery of the default server
  118.  
  119.     ServerNameBox.Selected(0) = True
  120.     BinderyObjList.Selected(0) = True
  121.  
  122. End Sub
  123.  
  124. Sub FormatInternetAddress (inString)
  125.     Dim nwString, outString As String
  126.     Dim index As Integer
  127.  
  128.     'Pretty printing for the hexidecimal network and node addresses
  129.     outString = "["
  130.     nwString = Mid$(inString, 1, 4)
  131.     For index = 1 To Len(nwString)
  132.        outString = outString & Format$(Hex$(Asc(Mid$(nwString, index, 1))), "00")
  133.     Next index
  134.  
  135.     outString = outString & "]["
  136.     nwString = Mid$(inString, 5, 6)
  137.     For index = 1 To Len(nwString)
  138.     outString = outString & Format$(Hex$(Asc(Mid$(nwString, index, 1))), "00")
  139.     Next index
  140.  
  141.     outString = outString & "]"
  142.  
  143.     inString = outString
  144. End Sub
  145.  
  146. Function GetConnections () As String
  147.  Dim connID As Integer
  148.  Dim fileServerName As String
  149.  Dim ccode, mode, connListSize As Integer
  150.  Dim numConnections As Integer
  151.  ReDim connListBuffer(50) As Integer
  152.  
  153.  ServerNameBox.Clear
  154.  
  155.  mode = 0
  156.  connListSize = 50
  157.  ccode = NWGetConnectionList(mode, connListBuffer(1), connListSize, numConnections)
  158.  
  159.  
  160.  For connID = 1 To numConnections
  161.     'for each connection in workstation's file server name table
  162.     'get the table entry, then see if it's null
  163.     
  164.     fileServerName = String$(48, 0)
  165.     NWGetFileServerName connID, fileServerName
  166.     If Left$(fileServerName, 1) <> Chr$(0) Then
  167.         'you have to explicitly look for a null in the first character,
  168.         'because Visual Basic doesn't know about null-terminated strings
  169.         '(a null prints as a space)
  170.         If connID = 1 Then GetConnections = fileServerName
  171.         ServerNameBox.AddItem fileServerName
  172.     End If
  173.     Next connID
  174.  
  175. End Function
  176.  
  177. Sub Rescan_Click ()
  178.    
  179.     ServerNameBox_DblClick  'same effect as if the user had
  180.                 'double-clicked on a file server name
  181.  
  182. End Sub
  183.  
  184. Sub RescanButton_Click ()
  185.     Dim server As String
  186.  
  187.     server = GetConnections()
  188.     ServerNameBox_DblClick  'same effect as if the user had
  189.                 'double-clicked on a file server name
  190. End Sub
  191.  
  192. Sub ScanUsers (server)
  193.  
  194.     Dim objectType As String * 6
  195.     Dim maxConns As Long
  196.     Dim ccode As Integer
  197.     Dim index As Integer
  198.     Dim nIndex As Integer
  199.     Dim nwUser As USER_INFO
  200.     Dim objectName As String * 48
  201.  
  202.     Screen.MousePointer = 11        'change mouse cursor to hourglass
  203.  
  204.     BinderyObjList.Clear
  205.     
  206.     ccode = NWGetConnectionHandle(server, ByVal 0, nwConn, ByVal 0&)
  207.     'get the connection handle to our default server
  208.     If (ccode) Then
  209.     MsgBox "Unable to get connection"
  210.     Exit Sub
  211.     End
  212.     End If
  213.  
  214.     ccode = NWGetConnectionNumber(nwConn, nwConnNumber)
  215.     'and get the connection number
  216.     If (ccode) Then
  217.     MsgBox "Unable to get connection number"
  218.     Exit Sub
  219.     End
  220.     End If
  221.  
  222.     ccode = NWGetInternetAddress(nwConn, nwConnNumber, myInetAddress)
  223.     Rem myInetAddress = spx1.LocalName
  224.     ' get our internet address and put it in a global for use later
  225.     If (ccode) Then
  226.     MsgBox "Unable to get internet address"
  227.     Exit Sub
  228.     End
  229.     End If
  230.     
  231.     ccode = NWGetFileServerInformation(nwConn, ByVal 0&, ByVal 0&, ByVal 0&, ByVal 0&, maxConns, ByVal 0&, ByVal 0&, ByVal 0&, ByVal 0&, ByVal 0&)
  232.     ' get the maximum number of connections the file server has used
  233.     If (ccode) Then
  234.     Exit Sub
  235.     End If
  236.  
  237.     ReDim netWareUsers(maxConns)
  238.     nIndex = 1
  239.     'loop through all the possible connection numbers to get
  240.      'all the logged in users
  241.  
  242.     For index = 1 To maxConns
  243.     ccode = NWGetConnectionInformation(nwConn, index, ByVal nwUser.objectName, nwUser.objectType, nwUser.objectID, ByVal nwUser.loginTime)
  244.     If ccode = 0 And Left$(nwUser.objectName, 1) <> Chr$(0) Then
  245.         BinderyObjList.AddItem nwUser.objectName
  246.         nwUser.connNumber = index
  247.         netWareUsers(nIndex) = nwUser
  248.         nIndex = nIndex + 1
  249.     End If
  250.     DoEvents
  251.     Next index
  252.  
  253. EndConns:
  254.     Screen.MousePointer = 0     'change mouse cursor back to how it was
  255.  
  256. End Sub
  257.  
  258. Sub ServerNameBox_DblClick ()
  259.     Dim server, prefServer As String
  260.     Dim index, ccode, connID As Integer
  261.  
  262.     prefServer = ServerNameBox.Text
  263.     
  264.     If Len(prefServer) = 0 Then
  265.     Rem no server selected
  266.     prefServer = ServerNameBox.List(0)
  267.     End If
  268.  
  269.     server = GetConnections()
  270.  
  271.     ScanUsers prefServer 'then go scan its bindery
  272.     index = SendMessage(ServerNameBox.hWnd, LB_FINDSTRING, ByVal -1, ByVal prefServer)
  273.     If (index <> LB_ERR) Then
  274.     ServerNameBox.Selected(index) = True
  275.     Else
  276.     ServerNameBox.Selected(0) = True
  277.     End If
  278.  
  279.     BinderyObjList.Selected(0) = True
  280. End Sub
  281.  
  282. Sub spx1_LinkEvent ()
  283.     
  284.     If spx1.Event Then
  285.     MsgBox "Link Error: " & spx1.Event
  286.     Exit Sub
  287.     End If
  288.  
  289. End Sub
  290.  
  291. Sub spx1_ReceiveData ()
  292.     
  293.     receiveList.Visible = True
  294.     disConnectButton.Enabled = True
  295.     connectButton.Enabled = False
  296.     receiveList.AddItem spx1.Received
  297.  
  298. End Sub
  299.  
  300. Sub spx1_SendData ()
  301.  
  302.     'Fired when the packet has been sent
  303.  
  304. End Sub
  305.  
  306. Sub userPictureDrop_DblClick ()
  307.     aboutForm.Show 1
  308. End Sub
  309.  
  310.