Declare Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" (lpNetResource As NETRESOURCE, ByVal lpPassword As String, ByVal lpUserName As String, ByVal dwFlags As Long) As Long Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetCancelConnection2A" (ByVal lpName As String, ByVal dwFlags As Long, ByVal fForce As Long) As Long
Type NETRESOURCE dwScope As Long dwType As Long dwDisplayType As Long dwUsage As Long lpLocalName As String lpRemoteName As String lpComment As String lpProvider As String End Type
Const RESOURCETYPE_DISK = &H1 Const RESOURCE_PUBLICNET = &H2
Const CONNECT_REMEMBER_NONE = 0 Const CONNECT_UPDATE_PROFILE = &H1 Const RESOURCEDISPLAYTYPE_GENERIC = &H0 Const RESOURCEUSAGE_CONNECTABLE = &H1
Function Net_Connect(strLocalDrive, strRemotePath, strUserName) As Long Dim NetR As NETRESOURCE NetR.dwScope = RESOURCE_PUBLICNET NetR.dwType = RESOURCETYPE_DISK NetR.dwDisplayType = RESOURCEDISPLAYTYPE_GENERIC NetR.dwUsage = RESOURCEUSAGE_CONNECTABLE NetR.lpLocalName = strLocalDrive NetR.lpRemoteName = strRemotePath NetR.lpComment = "" Net_Connect = WNetAddConnection2(NetR, vbNullString, strUserName, CONNECT_REMEMBER_NONE) End Function
Function Net_Disconnect(strLocalDrive As String, dwRememberFlag As Long, bForced As Boolean) As Long Net_Disconnect = WNetCancelConnection2(strLocalDrive, dwRememberFlag, bForced) End Function
------------------------------- Réponse au message : -------------------------------
Je souhaite créer une connexion à un ordi distant sans passer par la méthode Win95NetconnectDrive qui permet l'utilisation d'une boîte de dialogue Windows.
Bref, je voudrais un équivalent au langage de script NET USE LETTRE: \\NOMdelaMchine\Nomdela ressourcePartagée /yES
|