If IO.File.Exists(SKYTemplateFile) = False Then ‘文件不存在 If SKYTemplatePath.IndexOf("\\") = 0 Then If Connect(SKYTemplatePath, lpRemoteUsr, lpRemotePass) = False Then ShowMsgBox("...") Return False ElseIf IO.File.Exists(SKYTemplateFile) = False then ShowMsgBox("...") Return False End If Else ShowMsgBox("...") Return False
End If End If
Public Function Connect(ByVal lpRemoteName As String, ByVal lpRemoteUsr As String, ByVal lpRemotePass As String) As Boolean Dim intRtn As Integer
Try
Dim typNetResource As NETRESOURCE
With typNetResource .dwScope = RESOURCE_CONNECTED .dwType = RESOURCETYPE_DISK .dwDisplayType = RESOURCEDISPLAYTYPE_SHARE .dwUsage = RESOURCEUSAGE_CONTAINER ''.lpLocalName = LocalName .lpRemoteName = lpRemoteName End With
intRtn = WNetAddConnection2(typNetResource, lpRemotePass, lpRemoteUsr, CONNECT_UPDATE_PROFILE) Select Case intRtn Case 0 '连接 Case Else '连接Error Return False
End Select
Return True
Catch ex As Exception Throw ex Return False Finally End Try