Code : Tout sélectionner
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Connexion lecteur résseau", 438, 258, 300, 200)
$label_login = GUICtrlCreateLabel("Login", 40, 40, 30, 17)
$Input_login = GUICtrlCreateInput(@username, 96, 35, 185, 21)
$label_passwd = GUICtrlCreateLabel("Password", 42, 110, 50, 17)
$Input_password = GUICtrlCreateInput("", 98, 105, 185, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
$Button_connexion = GUICtrlCreateButton("Connexion", 312, 192, 73, 33)
$Label_encours = GUICtrlCreateLabel("Montage en cours ...", 42, 200, 100, 17)
GUICtrlSetState(-1,$GUI_HIDE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Button_connexion
connexion_map()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func connexion_map()
Local $login,$passwd,$ctrl,$err,$lecteur
$login=GUICtrlRead($Input_login)
$passwd=GUICtrlRead($Input_password)
$lecteur="V:"
If ($login="") Or ($passwd="") Then
MsgBox(16,"Erreur","Saisie d'identification incorrecte")
return 0
EndIf
GUICtrlSetState($Button_connexion,$GUI_HIDE)
GUICtrlSetState($Label_encours,$GUI_SHOW)
$ctrl=DriveMapAdd($lecteur,"\\TEST\"&$login,0,$login,$passwd)
$err=@error
GUICtrlSetState($Label_encours,$GUI_HIDE)
GUICtrlSetState($Button_connexion,$GUI_SHOW)
If ($ctrl=0) Then
MsgBox(16,"Erreur","Le montage de "&$lecteur&" a échoué"&@CRLF&"code erreur = "&$err)
return 0
EndIf
return 1
EndFunc