Gotha писал(а):вобще к ЛаН можно только аппаратно спрашивай местных провайдеров... а так нато ставить вопрос - к чему конкретно в ЛаНе подключаться
Set oNet = CreateObject("Wscript.Network")
ComputerName = oNet.ComputerName
Set oShell = CreateObject("Shell.Application")
Set oFolder = oShell.Namespace(49)
for each a in oFolder.items()
for each v in a.verbs
if instr(v.name,"Запретить") then
v.DoIt
end if
next
next
Public Declare Function WNetAddConnection Lib "mpr.dll" _
Alias "WNetAddConnectionA" _
(ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) _
As Long
Public Declare Function WNetCancelConnection Lib "mpr.dll" _
Alias "WNetCancelConnectionA" _
(ByVal lpszName As String, ByVal bForce As Long) _
As Long
Public Const WN_SUCCESS = 0
Public Const WN_NET_ERROR = 2
Public Const WN_BAD_PASSWORD = 6
Public Const WN_ALREDY_EXIST = 85
Public Const WN_NOT_FOUND_PATH = 67
Public Function AddConnection(ShareName As String, Resurs As String, PWD As String, LocalLetter As String) As Integer
Dim mShareName As String
On Local Error GoTo AddConnection_Err
mShareName = "\\" & ShareName & "\" & Resurs
AddConnection = WNetAddConnection(mShareName, PWD, LocalLetter)
AddConnection_End:
Exit Function
AddConnection_Err:
AddConnection = Err
MsgBox Error$
Resume AddConnection_End
End Function
Public Function CancelConnection(LocalLetter As String, force As Integer) As Integer
On Local Error GoTo CancelConnection_Err
CancelConnection = WNetCancelConnection(LocalLetter, force)
CancelConnection_End:
Exit Function
CancelConnection_Err:
CancelConnection = Err
MsgBox Error$
Resume CancelConnection_End
End Function
' использование функций:
' i = AddConnection("\\10.218.72.3\ASU_RTP1", "blinov", "G:")
' и
' CancelConnection "G:", False
' если параметр force = False, и текущее устройство
' используется, то функция не отключает устройство.
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 43