Bonjour à tous,
Se que je veux faire c'est lorsque mon application se load, me connecter :
lpszNetPath= "\\s02a\PRiVE\REVENU\Mon_dossier"
lpszLocalName= "X"
Si je comprend bien il faut que j'utilise WNetAddConnection! et lors de la fermeture de l'application je peux deconnecter ce lecteur.
Voici le code que j'utilise:
[code]
Public Declare Function WNetCancelConnection Lib "mpr.dll" Alias "WNetCancelConnectionA" (ByVal lpszName As String, ByVal bForce As Long) As Long
Public Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszLocalName As String) As Long
[\code]
[code]
Public Sub connexion_Click()
Dim strLocalDriveLetter As String
Dim strNetworkPathName As String
strLocalDriveLetter = "X:"
strNetworkPathName = "\\S02a\PRIVE\REVENU\Caisse_Depannage"
DoEvents
rc = WNetAddConnection(strNetworkPathName, strLocalDriveLetter)
End Sub
Public Sub deconnexion_Click()
rc = WNetCancelConnection("X:" + Chr(0), 0)
End Sub
[\code]
J'ai une erreur lors de l'exécution:
Bad DLL calling convention et l'arrêt se fait à la ligne
[code]
rc = WNetAddConnection(strNetworkPathName, strLocalDriveLetter)
[\code]
Savez-vous le pourquoi?
Systême Windows XP PRO
Windows NT Server