Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the name of a server with VB

Status
Not open for further replies.

bjwade62

Programmer
Oct 31, 2002
15
US
Does anyone know how to get the name of a server with code?
 
Sooooooo vague...... pls make it specific

All the Best Praveen Menon
pcmin@rediffmail.com
 
I'm trying to get the full path of a file on a server. It's on a mapped drive ie j:\0000\arch\0000-a1.dwg. I want to get something similar to \\servername\vol1:\projects\0000\arch\0000-a1.dwg. We have sevral offices with J:\drives. I want to find which server the file is on (with code).

Thanks,
Bernie
 
To get started view the Net command in a dos window. You can use this in a batch file, like command>>results.txt and then read the file. Like I said it's a good way to get started and works fairly well.
 
Declare Function GetFullPathName Lib "kernel32.dll" Alias "GetFullPathNameA" (ByVal lpFileName As String, ByVal nBufferLength As Long, ByVal lpBuffer As String, ByVal lpFilePart As String) As Long

See for details - this is a very useful guide to calling the Windows API from VB.
 
---------------------------------
Private Declare Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" (ByVal lpszLocalName As String, ByVal lpszRemoteName As String, cbRemoteName As Long) As Long

Private Sub Command1_Click()
Dim Buf As String * 256, l As Long
l = 255
WNetGetConnection "s:", Buf, l
MsgBox "Full path: " & Left$(Buf, l)
End Sub
---------------------------------- Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top