home *** CD-ROM | disk | FTP | other *** search
/ Dan Appleman's Visual Bas…s Guide to the Win32 API / Dan.Applmans.Visual.Basic.5.0.Programmers.Guide.To.The.Win32.API.1997.Ziff-Davis.Press.CD / VB5PG32.mdf / vbpg32 / samples5 / ch22 / dwnetrem.cls < prev    next >
Encoding:
Visual Basic class definition  |  1997-02-17  |  1.5 KB  |  48 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "dwRemoteNameInfo"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = False
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = False
  10. Option Explicit
  11. ' Copyright ⌐ 1997 by Desaware Inc. All Rights Reserved
  12.  
  13. Private Type REMOTE_NAME_INFO
  14.    lpUniversalName As Long
  15.    lpConnectionName As Long
  16.    lpRemainingPath As Long
  17. End Type
  18.  
  19. Public lpUniversalName As String
  20. Public lpConnectionName As String
  21. Public lpRemainingPath As String
  22.  
  23. Private Declare Function intWNetGetUniversalName Lib "mpr.dll" Alias "WNetGetUniversalNameA" (ByVal lpLocalPath As String, ByVal dwInfoLevel As Long, lpBuffer As Any, lpBufferSize As Long) As Long
  24.  
  25. ' We cheat slightly here, since a UNIVERSAL_NAME_INFO structure is very
  26. ' similar to REMOTE_NAME_INFO
  27. Public Function Load(lpLocalPath As String, dwInfoLevel As Long)
  28.    Dim res&
  29.    Dim tbuf()
  30.    Dim BufferSize&
  31.    ReDim tbuf(16384)
  32.    BufferSize = 16384
  33.    Dim Info As REMOTE_NAME_INFO
  34.   
  35.    
  36.    res = intWNetGetUniversalName(lpLocalPath, dwInfoLevel, tbuf(0), BufferSize)
  37.    If res = 0 Then
  38.       agCopyData tbuf(0), Info, Len(Info)
  39.       lpUniversalName = agGetStringFromPointer(Info.lpUniversalName)
  40.       If dwInfoLevel = REMOTE_NAME_INFO_LEVEL Then
  41.          lpConnectionName = agGetStringFromPointer(Info.lpConnectionName)
  42.          lpRemainingPath = agGetStringFromPointer(Info.lpRemainingPath)
  43.       End If
  44.    End If
  45.    ' We'll leave it for the parent to do the LastError stuff
  46.    Load = res
  47. End Function
  48.