Code du EXE // exe.cpp : Defines the entry point for the console application. // #include <windows.h> #include <stdio.h> #include "stdafx.h" #include #include <stdlib.h> extern "C" __declspec(dllimport) char* ConcatWorld(char *B); int main(int argc, char* argv[]) { char *var = ConcatWorld("Hello "); cout << var << endl; system("PAUSE"); return 0; } __________________________________________________________ Le code du dll // 2237.cpp : Defines the entry point for the DLL application. // #include "stdafx.h" #include <windows.h> #include <stdio.h> #include <conio.h> #include <malloc.h> #include <stdlib.h> BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { return TRUE; } extern "C" __declspec(dllexport) char* ConcatWorld(char* psz) { char *pret; int len = strlen(psz); pret = (char*) malloc(len + 8); if(!pret) return 0; strcpy(pret, psz); strcat(pret, "World"); return pret; }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question