Passage de paramètres?

bip98 Messages postés 104 Date d'inscription mercredi 23 avril 2003 Statut Membre Dernière intervention 29 avril 2008 - 10 mai 2005 à 13:42
vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 - 10 mai 2005 à 14:52
Bonjour,



J'ai un petite question, je vaidrais passer inp32 et oup32 dans la fonction FonctionDivers().

comment faire ?



Ce fragment de code commande le port LPT, il devrait lui envoyer la
valeur 255 depuis la fonction FonctionDivers(), mais il ne compile car
il ne reconnait pas (oup32).





typedef short _stdcall (*inpfuncPtr)(short portaddr);

typedef void _stdcall (*oupfuncPtr)(short portaddr, short datum);



void FonctionDivers();



int main(int argc, char *argv[])

{

HINSTANCE hLib;

inpfuncPtr inp32;

oupfuncPtr oup32;



/* Load the library */

hLib = LoadLibrary("inpout32.dll");



if (hLib == NULL)

{

printf("LoadLibrary Failed.\n");

return -1;

}



/* get the address of the function */



inp32 = (inpfuncPtr) GetProcAddress(hLib, "Inp32");



if (inp32 = = NULL)

{

printf("GetProcAddress for Inp32 Failed.\n");

return -1;

}





oup32 = (oupfuncPtr) GetProcAddress(hLib, "Out32");



if (oup32 == NULL)

{

printf("GetProcAddress for Oup32 Failed.\n");

return -1;

}



FonctionDivers();



FreeLibrary(hLib);



system("PAUSE");

return 0;

}





FonctionDivers()

{

(oup32)(0x378,255);

}

1 réponse

vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
10 mai 2005 à 14:52
Normal, tu dois définir oup32 en global, pour l'instant c'est une variable locale de main
0
Rejoignez-nous