TouperTinois |
J'ai testé ce type de programme mais dans ton cas tu fais une DLL d'une fonction pas d'une classe.
Donc quand moi j'essaie d'appeler de cette maniere une méthode de ma classe ca ne marche pas .
Je te donne mon exemple de DLL. Ce n'est qu'un exemple simple pour tester car mon but etant de faire la dLL d'une classe ACtions plus importante dans le cadre d'un projet.
J'espere que tu ve pourvoir m'aider car j'ai trop de mùalk et je sature a force lol.
Voila la .h de la creation de la dll
Code :
- //***************************************************************************
- //Classe d'exception pour la connexion internet
- //***************************************************************************
-
- #ifndef __DLL_MODULE_H__
- #define __DLL_MODULE_H__
-
- #ifdef MADLL_EXPORTS
- #define LINKDLL __declspec(dllexport)
- #pragma message("Building DLL" )
- #else
- #define LINKDLL __declspec(dllimport)
- #pragma message("Importing DLL" )
- #endif
-
-
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <math.h>
- #include <iostream.h>
- #include <winsock2.h>
-
- #pragma comment(lib, "ws2_32.lib" )
-
-
-
- class LINKDLL erreur
- {
- private:
- int cause;
- public:
- erreur(int pcause);
- int get_cause();
- void afficher_Erreur(int);
-
- };
-
- //---------------------------------------------------------------------------
- #endif
|
Et le .cpp
Code :
- #include "erreur.h"
- #define _WSAEINTR "10004 Interrupted function call"
- #define _WSAEACCES "10013 Permission denied"
- #define _WSAEFAULT "10014 Bad address"
- #define _WSAEINVAL "10022 Invalid argument"
- #define _WSAEMFILE "10024 Too many open files"
- #define _WSAEWOULDBLOCK "10035 Resource temporarily unavailable"
- #define _WSAEINPROGRESS "10036 Operation now in progress"
- #define _WSAEALREADY "10037 Operation already in progress"
- #define _WSAENOTSOCK "10038 Socket operation on non-socket"
- #define _WSAEDESTADDRREQ "10039 Destination address required"
- #define _WSAEMSGSIZE "10040 Message too long"
- #define _WSAEPROTOTYPE "10041 Protocol wrong type for socket"
- #define _WSAENOPROTOOPT "10042 Bad protocol option"
- #define _WSAEPROTONOSUPPORT "10043 Protocol not supported"
- #define _WSAESOCKTNOSUPPORT "10044 Socket type not supported"
- #define _WSAEOPNOTSUPP "10045 Operation not supported"
- #define _WSAEPFNOSUPPORT "10046 Protocol family not supported"
- #define _WSAEAFNOSUPPORT "10047 Address family not supported by protocol family"
- #define _WSAEADDRINUSE "10048 Address already in use"
- #define _WSAEADDRNOTAVAIL "10049 Cannot assign requested address"
- #define _WSAENETDOWN "10050 Network is down"
- #define _WSAENETUNREACH "10051 Network is unreachable"
- #define _WSAENETRESET "10052 Network dropped connection on reset"
- #define _WSAECONNABORTED "10053 Software caused connection abort"
- #define _WSAECONNRESET "10054 Connection reset by peer"
- #define _WSAENOBUFS "10055 No buffer space available"
- #define _WSAEISCONN "10056 Socket is already connected"
- #define _WSAENOTCONN "10057 Socket is not connected"
- #define _WSAESHUTDOWN "10058 Cannot send after socket shutdown"
- #define _WSAETIMEDOUT "10060 Connection timed out"
- #define _WSAECONNREFUSED "10061 Connection refused"
- #define _WSAEHOSTDOWN "10064 Host is down"
- #define _WSAEHOSTUNREACH "10065 No route to host"
- #define _WSAEPROCLIM "10067 Too many processes"
- #define _WSASYSNOTREADY "10091 Network subsystem is unavailable"
- #define _WSAVERNOTSUPPORTED "10092 WINSOCK.DLL version out of range"
- #define _WSANOTINITIALISED "10093 Successful _WSAStartup not yet performed"
- #define _WSAEDISCON "10094 Graceful shutdown in progress"
- #define _WSATYPE_NOT_FOUND "10109 Class type not found"
- #define _WSAHOST_NOT_FOUND "11001 Host not found"
- #define _WSATRY_AGAIN "11002 Non-authoritative host not found"
- #define _WSANO_RECOVERY "11003 This is a non-recoverable error"
- #define _WSANO_DATA "11004 Valid name, no data record of requested type"
- erreur::erreur( int pcause )
- {
- cause = pcause;
- }
- int erreur::get_cause()
- {
- return cause;
- }
- void erreur::afficher_Erreur(int pcode)
- {
- switch (pcode)
- {
- case 10004: printf("%s\n",_WSAEINTR);
- break;
- case 10013: printf("%s\n",_WSAEACCES);
- break;
- case 10014: printf("%s\n",_WSAEFAULT);
- break;
- case 10022: printf("%s\n",_WSAEINVAL);
- break;
- case 10024: printf("%s\n",_WSAEMFILE);
- break;
- case 10035: printf("%s\n",_WSAEWOULDBLOCK);
- break;
- case 10036: printf("%s\n",_WSAEINPROGRESS );
- break;
- case 10037: printf("%s\n",_WSAEALREADY );
- break;
- case 10038: printf("%s\n",_WSAENOTSOCK );
- break;
- case 10039: printf("%s\n",_WSAEDESTADDRREQ );
- break;
- case 10040: printf("%s\n",_WSAEMSGSIZE );
- break;
- case 10041: printf("%s\n",_WSAEPROTOTYPE );
- break;
- case 10042: printf("%s\n",_WSAENOPROTOOPT );
- break;
- case 10043: printf("%s\n",_WSAEPROTONOSUPPORT );
- break;
- case 10044: printf("%s\n",_WSAESOCKTNOSUPPORT );
- break;
- case 10045: printf("%s\n",_WSAEOPNOTSUPP );
- break;
- case 10046: printf("%s\n",_WSAEPFNOSUPPORT );
- break;
- case 10047: printf("%s\n",_WSAEAFNOSUPPORT );
- break;
- case 10048: printf("%s\n",_WSAEADDRINUSE );
- break;
- case 10049: printf("%s\n",_WSAEADDRNOTAVAIL );
- break;
- case 10050: printf("%s\n",_WSAENETDOWN);
- break;
- case 10051: printf("%s\n",_WSAENETUNREACH );
- break;
- case 10052: printf("%s\n",_WSAENETRESET );
- break;
- case 10053: printf("%s\n",_WSAECONNABORTED );
- break;
- case 10054: printf("%s\n",_WSAECONNRESET);
- break;
- case 10055: printf("%s\n",_WSAENOBUFS);
- break;
- case 10056: printf("%s\n",_WSAEISCONN );
- break;
- case 10057: printf("%s\n",_WSAENOTCONN );
- break;
- case 10058: printf("%s\n",_WSAESHUTDOWN );
- break;
- case 10060: printf("%s\n",_WSAETIMEDOUT );
- break;
- case 10061: printf("%s\n",_WSAECONNREFUSED );
- break;
- case 10064: printf("%s\n",_WSAEHOSTDOWN );
- break;
- case 10065: printf("%s\n",_WSAEHOSTUNREACH );
- break;
- case 10067: printf("%s\n",_WSAEPROCLIM );
- break;
- case 10091: printf("%s\n",_WSASYSNOTREADY );
- break;
- case 10092: printf("%s\n",_WSAVERNOTSUPPORTED );
- break;
- case 10093: printf("%s\n",_WSANOTINITIALISED );
- break;
- case 10094: printf("%s\n",_WSAEDISCON );
- break;
- case 10109: printf("%s\n",_WSATYPE_NOT_FOUND );
- break;
- case 11001: printf("%s\n",_WSAHOST_NOT_FOUND );
- break;
- case 11002: printf("%s\n",_WSATRY_AGAIN );
- break;
- case 11003: printf("%s\n",_WSANO_RECOVERY );
- break;
- case 11004: printf("%s\n",_WSANO_DATA );
- break;
- default : printf("Nothing..." );
- }
- }
|
Si tu ve que je t'envoie mon main de test demande moi je te le posterai.
Merci d'avance
a+ |