I have some code that calls a DLL named James and passes
2 integers and a string to it:
The James DLL code looks like this:
When I try to compile James.dll, I get problems with
the strcpy:
What am I doing wrong?
2 integers and a string to it:
Code:
int CallJames(void)
{
/* get handle to dll */
HINSTANCE hGetProcIDDLL = LoadLibrary("C:\\WINDOWS\\system32\\James.dll");
/* get pointer to the function in the dll*/
FARPROC lpfnGetProcessID = GetProcAddress(HMODULE(hGetProcIDDLL), "sum");
/* Define the Function in the DLL for reuse. This is just prototyping
the dll's function. A mock of it. Use "stdcall" for maximum compatibility.
*/
typedef int (__stdcall * pICFUNC)(int,int,char*);
pICFUNC MyFunction;
MyFunction = pICFUNC(lpfnGetProcessID);
char Msg[25];
/* The actual call to the function contained in the dll */
int intMyReturnVal = MyFunction(1,2,Msg);
/* Release the Dll */
FreeLibrary(hGetProcIDDLL);
/* The return val from the dll */
return intMyReturnVal;
}
The James DLL code looks like this:
Code:
#include "stdafx.h" // Standard MFC libraries
int _stdcall sum(char Msg, int x, int y)
{
strcpy(Msg,'got here');
return x + y;
}
When I try to compile James.dll, I get problems with
the strcpy:
Code:
error C2664: 'strcpy' : cannot convert parameter 1 from 'char' to 'char *'
What am I doing wrong?