/*
 * 這是 DLL 裡面的 Function
 */

__declspec(dllexport) int __cdecl add(int a, int b)
{
	return a + b;
}


/*
 * DLL的客戶端程式
 */

#include <Windows.h>

typedef int (__cdecl *BinaryOp)(int op1, int op2);

int _tmain(int argc, _TCHAR* argv[])
{
	BinaryOp bop;

	HMODULE lib = LoadLibrary(_T("D:\\VC_Projects\\DllTest\\Debug\\DllTest.dll"));
	if (lib != NULL)
	{
		// 下面這個詭異的名稱是用 Dependency Walker 看到的
		bop = (BinaryOp)GetProcAddress(lib, "?add@@YAHHH@Z");
		if (bop != 0)
		{
			printf("add(5, 9) = %d\n", bop(5, 9));
		}
	}

	return 0;
}