morickno
Messages postés117Date d'inscriptionvendredi 22 avril 2005StatutMembreDernière intervention26 juin 2007
-
29 sept. 2006 à 16:31
Dolphin Boy
Messages postés630Date d'inscriptionvendredi 5 mai 2006StatutMembreDernière intervention17 février 2007
-
29 sept. 2006 à 16:54
Peut t'on par programmation, connecter des lecteur reseau avec profil et mot de passe, et si oui, pouvez vous m'orienter SVP.
Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long
Private Declare Function WNetCancelConnection Lib "mpr.dll" Alias "WNetCancelConnectionA" (ByVal lpszName As String, ByVal bForce As Long) As Long
Const WN_SUCCESS = 0 ' The function was successful.
Const WN_NET_ERROR = 2 ' An error occurred on the network.
Const WN_BAD_PASSWORD = 6 ' The password was invalid.
Private Declare Function WNetConnectionDialog Lib "mpr.dll" (ByVal hwnd As Long, _
ByVal dwType As Long) As Long
Private Declare Function WNetDisconnectDialog Lib "mpr.dll" (ByVal hwnd As Long, _
ByVal dwType As Long) As Long
Const RESOURCETYPE_DISK = &H1
Const RESOURCETYPE_PRINT = &H2
Function AddConnection(MyShareName As String, MyPWD As String, UseLetter As String) As Integer
On Local Error GoTo AddConnection_Err
AddConnection = WNetAddConnection(MyShareName, MyPWD, UseLetter)
AddConnection_End:
Exit Function
AddConnection_Err:
AddConnection = Err
MsgBox Error$
Resume AddConnection_End
End Function
Function CancelConnection(DriveLetter As String, Force As Integer) As Integer
On Local Error GoTo CancelConnection_Err
CancelConnection = WNetCancelConnection(DriveLetter, Force)
CancelConnection_End:
Exit Function
CancelConnection_Err:
CancelConnection = Err
MsgBox Error$
Resume CancelConnection_End
End Function
Function Lettre() As String
Dim i As Integer
'Dim test
For i = 90 To 70 Step -1 'de Z à E
'test = Chr(i)
On Error Resume Next
If Dir(Chr(i) & ":", vbDirectory) = "" Then
If Err.Number = 0 Then
Lettre = Chr(i) & ":"
Exit For
End If
End If
On Error GoTo 0
Next
End Function
Function AddConnection_Dialog() As Long
'Dim x As Long
'Connecter un lecteur réseau
AddConnection_Dialog = WNetConnectionDialog(0, RESOURCETYPE_DISK)
'Déconnecter un lecteur réseau
'x = WNetDisconnectDialog(Me.hwnd, RESOURCETYPE_DISK)
'Connecter une imprimante
'x = WNetConnectionDialog(Me.hwnd, RESOURCETYPE_PRINT)
'Déconnecter une imprimante
'x = WNetDisconnectDialog(Me.hwnd, RESOURCETYPE_PRINT)
End Function