VB.NET - Connexion SSH (Extraputty.dll)

scoob79 Messages postés 27 Date d'inscription mercredi 20 janvier 2010 Statut Membre Dernière intervention 5 septembre 2018 - 17 août 2018 à 10:08
vb95 Messages postés 3416 Date d'inscription samedi 11 janvier 2014 Statut Contributeur Dernière intervention 31 mai 2023 - 21 août 2018 à 12:36
Bonjour,

j'ai un soucis avec le code suivant, je n'arrive pas à me connecter j'ai le message d'erreur suivant :

Private Declare Function SendRcvData Lib "ExtraPuTTY.dll" (ByVal ConnexionId As Long, ByVal Command As String, ByVal title As String, ByVal comment As String, ByVal capt As Long, ByRef data As String, ByVal Sizedata As Long, ByVal Settings As Long) As Integer


Dans un premier temps je pensais que le problème venais du fait que putty était ouvert, mais pas du tout. Ensuite j'ai, en faisant un CloseAllConnexion() pendant l’exécution, je me suis aperçu que cela faisait avancer le code jusqu’à la fin où la j'ai une erreur 1.

Quelqu'un à une idée ?

@+

Code :

Public Class Form1
    Public Declare Function Connexion Lib "ExtraPuTTY.dll" (ByVal TragetName As String, ByRef ConnexionId As Long, ByVal Log As String, ByVal Pass As String, ByVal Display As Integer, ByVal proto As Long, ByVal portnumber As Long, ByVal rapport As Long, ByVal CallBackRcvData As Integer) As Integer
    Public Declare Function CloseAllConnexion Lib "ExtraPuTTY.dll" () As Integer
Private Declare Function SendRcvData Lib "ExtraPuTTY.dll" (ByVal ConnexionId As Long, ByVal Command As String, ByVal title As String, ByVal comment As String, ByVal capt As Long, ByRef data As String, ByVal Sizedata As Long, ByVal Settings As Long) As Integer
    '**************************************   SendRcvData  *******************************************************************
    'Parameter                           Description
    'ConnexionId         Connexion ID set by Connexion Function (shall be > 0).
    'Command             Data to send on the target, if the parameter is null the function is configured only in reception way.
    'Title               Title of your command,used only if extraputty report is activate.
    'Comments            Comments of your command,used only if extraputty report is activate.
    'TimeCapture         Time used to capture the reply data in ms.
    'DataRcv             Buffer which contains the data received if TimerCapture is > 0.
    'MaxSizeofData       Size of DataRcv Buffer or maximum data size in DataRcv (1 < MaxSizeofData < 20 000 000)
    'Settings            Bit fields of settings (2^0 : CRLF (0 send,1 not send),...reserved)

    '****************************************************************************************************************************


    Public Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim result As Integer, CallBAckAdr As Long, ConnexionId_SSH As Long
        Dim Nom_SRV, LOG_ID, LOG_PWD, PuttyVisible, CMD, SendCMD, CAC
        CallBAckAdr = 0
        Dim isConnected As Long = 0
        '**********************************************************
        '           INFORMATIONS DE CONNEXION
        '**********************************************************
        Nom_SRV = "10.69.115.12"
        LOG_ID = "okaspar"
        LOG_PWD = "!j3suis1G33K!"
        PuttyVisible = 1 '1=Oui 0=Non
        CMD = "exit"
        '**********************************************************
        '              Connexion au serveur
        '**********************************************************
        CAC = CloseAllConnexion()
        result = Connexion(Nom_SRV, isConnected, LOG_ID, LOG_PWD, PuttyVisible, 1, 22, 0, CallBAckAdr)
        ' test si la connexion est OK
        If (result <> 0) Then
            MsgBox("Erreur n° " & result)
        Else
            MsgBox("Connecté " & result)
            'SendCMD = SendRcvData(ConnexionId_SSH, CMD, "", "", 15000, DataRcv, 1000000, 0)
        End If

        '**********************************************************
        '           Fermer toutes les connexions
        '**********************************************************
        CAC = CloseAllConnexion()
    End Sub
End Class


Le code vient de cette page https://codes-sources.commentcamarche.net/forum/affich-1449614-vba-connexion-ssh-extraputty-dll#p10087799

2 réponses

vb95 Messages postés 3416 Date d'inscription samedi 11 janvier 2014 Statut Contributeur Dernière intervention 31 mai 2023 165
17 août 2018 à 20:11
bonjour
Déjà commence par déclarer correctement ces variables
Dim Nom_SRV, LOG_ID, LOG_PWD, PuttyVisible, CMD, SendCMD, CAC

0
scoob79 Messages postés 27 Date d'inscription mercredi 20 janvier 2010 Statut Membre Dernière intervention 5 septembre 2018
21 août 2018 à 10:40
Salut,

Alors petite correction mon message d'erreur est :

Une exception de première chance de type 'System.DllNotFoundException' s'est produite dans WindowsApplication1.exe

Je viens de corriger les déclaration et j'ai toujours le même problème.

Merci de ton aide.

@+
0
vb95 Messages postés 3416 Date d'inscription samedi 11 janvier 2014 Statut Contributeur Dernière intervention 31 mai 2023 165
21 août 2018 à 12:36
Bonjour
Tu as un problème de dll ! tu es sûr que ta Dll ExtraPuTTY.dll est bien sr ton PC à la bonne place ;
Car DllNotFoundException signifie en bon français : exception Dll non trouvée .
Difficile de t'aider plus
0
Rejoignez-nous