Problème sur l'utilisation d'une dll sous VB

Résolu
goffle Messages postés 78 Date d'inscription mercredi 11 mai 2005 Statut Membre Dernière intervention 3 juillet 2012 - 7 août 2009 à 20:46
goffle Messages postés 78 Date d'inscription mercredi 11 mai 2005 Statut Membre Dernière intervention 3 juillet 2012 - 8 août 2009 à 19:40
Bonjour,

J'ai réaliser il y a quelque temps une programme qui me permettait de contrôler le port parallèle grâce a la dll inpout32 sous code::blocks en C++.

J'aimerais reprendre ce programme sous VB toujours en C++ . Je copie exactement le même header et pourtant VB me sors des erreurs :

Error 1 error C2059: syntax error : 8
Error 2 error C2059: syntax error : 9
Error 3 error C2065: 'Inp32' : undeclared identifier 23
Error 4 error C2065: 'COM_Inp' : undeclared identifier 23
Error 5 error C2146: syntax error : missing ';' before identifier 'GetProcAddress' 23
.....



et voici mon code :
#ifndef INPOUT32HEADER_H_INCLUDED
#define INPOUT32HEADER_H_INCLUDED



HINSTANCE COM_hLib = LoadLibrary(_T("INPOUT32.dll")); 

typedef short _stdcall (*COM_Inp)(short AddrPort);
typedef void _stdcall (*COM_Outp)(short AddrPort, short Donnees);



inline int COM_Init()

{
   

    if (COM_hLib == NULL)    // Chargement de la DLL impossible
    {
        return -1;
    }

    Inp32 = (COM_Inp) GetProcAddress(COM_hLib, "Inp32");//pointeur définit sur cette fonction

    if (Inp32 == NULL) // Pointage sur cette fonction impossible
    {
        return -2;
    }

    COM_Outp = (COM_Outp) GetProcAddress(COM_hLib, "Out32"); //pointeur définit sur cette fonction

if (COM_Outp == NULL) // Pointage sur cette fonction impossible
    {
        return -3;
    }
    return 0; // tout à bien fonctionné
}

inline void COM_Fin() // Libère la DLL

{
    FreeLibrary(COM_hLib);
}

#endif // INPOUT32HEADER_H_INCLUDED



Pouvez vous m'aidez a résoudre mon problème ??? merci

5 réponses

cs_juju12 Messages postés 966 Date d'inscription samedi 3 avril 2004 Statut Membre Dernière intervention 4 mars 2010 4
8 août 2009 à 18:13
Non,c'est la parenthèse qui est mal placée.
Ceci est correct :
typedef short (_stdcall *COM_Inp)(short AddrPort);
typedef void (_stdcall *COM_Outp)(short AddrPort, short Donnees);


_stdcall ou __stdcall sont tous deux acceptés en l'occurence par VS.
3
cs_rt15 Messages postés 3874 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 7 novembre 2014 13
8 août 2009 à 14:35
Salut,

VB ???? Tu veux direz VS ou VC j'espère...

Ensuite, bin si tu déclares pas Inp32, le compilo dit qu'il est pas déclaré, quoi de plus normal ?

Vu que ta fonction renvoie un entier, c'était peut être une variable globale dans ton programme original.

Et ton .h là, il n'a aucune include, c'est un peu bizarre.
0
goffle Messages postés 78 Date d'inscription mercredi 11 mai 2005 Statut Membre Dernière intervention 3 juillet 2012
8 août 2009 à 15:44
ha mince j'ai mis le mauvais header :
voici l'original qui ne passe pas :

#include "stdafx.h"
#include "windows.h"

#ifndef INPOUT32HEADER_H_INCLUDED
#define INPOUT32HEADER_H_INCLUDED

typedef short _stdcall (*COM_Inp)(short AddrPort);
typedef void _stdcall (*COM_Outp)(short AddrPort, short Donnees);
HINSTANCE COM_hLib;
COM_Inp  Lire;
COM_Outp Ecrire;


inline int COM_Init()

{
    COM_hLib = LoadLibrary("inpout32.dll"); // chargement de la DLL

    if (COM_hLib == NULL)    // Chargement de la DLL impossible
    {
        return -1;
    }

    Lire = (COM_Inp) GetProcAddress(COM_hLib, "Inp32");//pointeur définit sur cette fonction

    if (Lire == NULL) // Pointage sur cette fonction impossible
    {
        return -2;
    }


    Ecrire = (COM_Outp) GetProcAddress(COM_hLib, "Out32"); //pointeur définit sur cette fonction

    if (Ecrire == NULL) // Pointage sur cette fonction impossible
       {
        return -3;
    }

    return 0; // tout à bien fonctionné
}

inline void COM_Fin() // Libère la DLL

{
    FreeLibrary(COM_hLib);
}

#endif // INPOUT32HEADER_H_INCLUDED


les erreurs :
Error 1 error C2059: syntax error : '(' 7
Error 2 error C2059: syntax error : '(' 8

Error 3 error C2146: syntax error : missing ';' before identifier 'Lire' 10
Error 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 10

...

Error 10 error C2146: syntax error : missing ';' before identifier 'GetProcAddress' 24
ect ....

Oui c'est bien (VS) Visual studio 2008
merci
0
cs_rt15 Messages postés 3874 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 7 novembre 2014 13
8 août 2009 à 15:59
J'ai pas Visual ici...

C'est les déclarations de COM_Inp et COM_Outp qu'il n'aime pas.
Essaie en remplaçant _stdcall par __stdcall (Deux underscores).
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
goffle Messages postés 78 Date d'inscription mercredi 11 mai 2005 Statut Membre Dernière intervention 3 juillet 2012
8 août 2009 à 19:40
MERCI juju12 ^^ c'était ca le problème (et merci rt15 aussi )

J'avais déjà essayé avec les 2 underscores et ca ne changeais rien.

vous m'avez bien aidé !

@ bientôt
0
Rejoignez-nous