15,471
社区成员
发帖
与我相关
我的任务
分享
EXPORTS
xxx0=??0xxx@@QAE@XZ
xxx1=??1xxx@@QAE@XZ
// DLL中类定义
class c
{
public:
int m;
int Get();
void Set(int n);
};
int c::Get()
{
return m;
}
void c::Set(int n)
{
m = n;
}
// DEF文件
LIBRARY "Test"
EXPORTS
Get
Set
// EXE的调用代码
class c
{
public:
int m;
};
typedef int (__thiscall* FUNCTION_C_GET)(c* Object);
typedef void (__thiscall* FUNCTION_C_SET)(c* Object, int n);
void Test()
{
HMODULE h = LoadLibrary(_T("Test.dll"));
FUNCTION_C_GET c_Get = (FUNCTION_C_GET)GetProcAddress(h, "Get");
FUNCTION_C_SET c_Set = (FUNCTION_C_SET)GetProcAddress(h, "Set");
c x;
c_Set(&x, 1);
int i = c_Get(&x);
}