[AccessD] Linked Tables - UNC Path

Gustav Brock gustav at cactus.dk
Fri May 7 07:02:43 CDT 2004


Hi Mark

> My latest department deployment has tested fine with one exception.  How can
> I force UNC naming for the linked tables?  I looked over some published
> relinking code, but was not prepared to drop in any code that could possibly
> involve user intervention.

This may not be that easy but have a look here:

   http://www.mvps.org/vb/samples.htm#UncName


For remote drive letters only, this module could be used.

<code>

Option Compare Database
Option Explicit

Private Const UNIVERSAL_NAME_INFO_LEVEL As Long = &H1&

Private Declare Function WNetGetUniversalName Lib "mpr.dll" Alias "WNetGetUniversalNameA" ( _
  ByVal lpLocalPath As String, _
  ByVal dwInfoLevel As Long, _
  ByRef lpBuffer As Any, _
  ByRef lpBufferSize As Long) _
  As Long

Private Type UNIVERSAL_NAME_INFO
  lpUniversalName As String * &H400&
End Type

Public Function GetUniversalPath( _
  ByVal strDrivePath As String) _
  As String

' Get UNC path from remote drive letter or drive letter and file name.
' Empty string is returned for local or non-mapped drive letters.
' Remote path is *not* validated except for the drive letter.
'
' Example:

'   s:\docs\letter.txt
'
' may return
'
'   \\FS1\SYS\DATA\docs\letter.txt
'
' 2002-03-25. Cactus Data ApS, CPH.
  
  Dim typBuffer   As UNIVERSAL_NAME_INFO
  Dim lngBuffer   As Long
  Dim strPath     As String
  
  ' Obtain needed buffer size.
  Call WNetGetUniversalName(strDrivePath, UNIVERSAL_NAME_INFO_LEVEL, 0, lngBuffer)
  ' Retrieve UNC info.
  Call WNetGetUniversalName(strDrivePath, UNIVERSAL_NAME_INFO_LEVEL, typBuffer, lngBuffer)
  
  ' Extract UNC path from mixed buffer.
  strPath = typBuffer.lpUniversalName
  strPath = Mid$(strPath, InStr(strPath, vbNullChar) + 1)
  strPath = Left$(strPath, InStr(strPath, vbNullChar) - 1)

  GetUniversalPath = strPath

End Function

</code>

Beware of line breaks.

/gustav




More information about the AccessD mailing list