[Link dynamic]fichier excutable au lieu d'une DLL
Bonjour, je cherche à charger dans un exécutable des fonctions se trouvant dans un autre binaire celui-ci étant un exe et non une DLL.
Je n'ai pas de succès dans mon entreprise.:cry:
Sous VS2010, je crée l'exe consolePrj.exe suivant:
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
void superPrint(void)
{
printf("super print\n");
}
int _tmain(int argc, _TCHAR* argv[])
{
superPrint();
getchar();
return 0;
} |
et j'essaie de l'importer sous un autre exe avec le code suivant :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
typedef void superPrintPtr(void);
int _tmain(int argc, _TCHAR* argv[])
{
HMODULE hConsolePrj = LoadLibrary(TEXT("consolePrj.exe"));
superPrintPtr* superPrint = (superPrintPtr*)GetProcAddress(hConsolePrj, "superPrint");
if (superPrint != NULL)
{
superPrint();
}
getchar();
return 0;
} |
Dans ce cas il ne veut rien savoir GetProcAddress renvoie NULL.