编译器:VS2010
需要的知识:DLL的编写和使用
1.dllmain.cpp
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
MessageBoxA(NULL,"DLL_PROCESS_ATTACH","TEST",MB_OK);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
MessageBoxA(NULL,"DLL_PROCESS_DETACH","TEST",MB_OK);
break;
}
return TRUE;
}
DLL_PROCESS_ATTACH:表示该DLL第一次装载进进程空间中执行的代码
DLL_PROCESS_DETACH:表示该DLL脱离进程空间时候执行的代码
MessageBoxA函数在windows.h头文件中
2.dllTesxt.cpp
#include "stdafx.h"
#include "dllTest.h"
#include <iostream>
using namespace std;