mymaths.cpp

来自「VC++中动态链接库实例」· C++ 代码 · 共 57 行

CPP
57
字号
// mymaths.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "mymaths.h"

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
    switch (ul_reason_for_call)
	{
		case DLL_PROCESS_ATTACH:
		case DLL_THREAD_ATTACH:
		case DLL_THREAD_DETACH:
		case DLL_PROCESS_DETACH:
			break;
    }
    return TRUE;
}


// This is an example of an exported variable
MYMATHS_API int nMymaths=0;

// This is an example of an exported function.
MYMATHS_API int fnMymaths(void)
{
	return 42;
}

// This is the constructor of a class that has been exported.
// see mymaths.h for the class definition
CMymaths::CMymaths()
{ 
	return; 
}
MYMATHS_API int summary(int n)
{
	int sum=0;
	int i;
	for(i=1;i<=n;i++)
		sum+=i;
	return sum;
}
MYMATHS_API int Factorial(int n)
{
  int fact=1;
  int i;
  for(i=1;i<=n;i++)
	  fact*=i;
  return fact;
  
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?