重生之都市剑侠百度云:In exe export function like below, and add .def file add foo to exports.

来源:百度文库 编辑:九乡新闻网 时间:2024/05/05 03:19:22
In exe export function like below, and add .def file add foo to exports.

__declspec(dllexport) int __stdcall foo(int i, int j)
{
return i+j;
}

In another exe file invoke function like this:
 

typedef int (__stdcall *FOO)(int, int);
 
HMODULE hModule = LoadLibrary("C:\\Export.exe");
if (hModule != NULL)
{
FOO pFun = (FOO)GetProcAddress(hModule, "foo");
if (pFun != NULL)
{
TRACE("%d\n", pFun(1, 3));
}
}