BOOL APIENTRY DllMain(HMODULE , DWORD ul_reason_for_call, LPVOID )
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
int ThisIsAFunction (int aa)
{
cout<<"雷好雷好!!!!"<
}
程序代码:
typedef int (*DllFun)(int);
int _tmain(int argc, _TCHAR* argv[])
{
HMODULE hDLL = LoadLibraryA ("H:\\Dlls\\DllForTest.dll");
if (hDLL == NULL)
{
cout<<"装载DLL失败!!!!!!!!!!!!"<
exit (-1);
}
DllFun fun;
fun = (DllFun)GetProcAddress (hDLL, "ThisIsAFunction");
cout<<"准备进入DLL函数!"<
cout<<"Dll function has exited with coed"<
return 0;
}