잠토의 잠망경

명시적인 로드 본문

공부/API

명시적인 로드

잠수함토끼 2008. 9. 9. 21:23
#undef UNICODE
#include 
#include 

typedef int (*pFunction)(int,int);
 
void RunLink()
{
	HINSTANCE hInst;
	pFunction pFunc;
	//명시적인 로드를 위한 LoadLibrary 함수이다.
	hInst=LoadLibrary("[40]DLLExternC.dll");
	//Dll 모듈에서 AddInteger라는 이름의 함수를 얻오는 함수이다.
	pFunc=(pFunction)GetProcAddress(hInst,"AddInteger");
	//함수를 직접호출하는 문장이다.
	int Result=pFunc(1,2);
	//함수의 결과를 출력한다.
	printf("Result: %d\n",Result);
	//모듈 사용이 끝났으므로 Dll의 usage count를 1줄인다.
	FreeLibrary(hInst);

}


int main(void)
{
	RunLink();
	return 0;
}
Comments