-1
je charge une dll dans mon code C++ mais quand exécuter j'obtiens l'erreur:fonction de la charge avec des paramètres de dll
dll:
`extern "C" __declspec(dllexport) int Add(int a,int b)
{
return a+b;
}`
mon fichier console:
typedef int(__stdcall *f_funci) (int , int);
int main()
{
HINSTANCE hGetProcIDDLL = LoadLibrary("ConsoleApplication1.dll");
if (!hGetProcIDDLL) {
std::cout << "could not load the dynamic library" << std::endl;
system("pause");
return EXIT_FAILURE;
}
f_funci funci = 0;
funci = (f_funci)GetProcAddress(hGetProcIDDLL, "Add");
if (!funci) {
std::cout << "could not locate the function" << std::endl;
system("pause");
return EXIT_FAILURE;
}
int t = 0;
t= (*funci)(2, 3);
std::cout << "funci() returned "<<t<< std::endl;
system("pause");
return EXIT_SUCCESS;
}
cette erreur: enter image description here
Je ne vois pas __stdcall dans la déclaration de fonction - mais vous l'avez ajouté à la définition du pointeur. Si vous appelez la fonction avec de mauvaises conventions d'appel, vous obtiendrez des erreurs comme indiqué sur l'écran d'impression –