VS2010 常用功能代码段

1.VS编译生成事件时复制文件

1 xcopy $(TargetPath)$(SolutionDir)SDK\Debug\ /y
2 xcopy $(TargetDir)$(TargetName).lib $(SolutionDir)SDK\Debug\ /y
3 xcopy $(ProjectDir)DetectorSDK.h $(SolutionDir)SDK\ /y

2.导出DLL头文件与CPP文件

//dll_test.h
#ifndef _DLL_TEST_INCLUDE_
#define _DLL_TEST_INCLUDE_

#ifndef TEST_SDK_API
#define TEST_SDK_API extern "C" __declspec(dllimport) 
#endif

TEST_SDK_API int __stdcall add(int x, int y);

#endif

/*---------------------------------------*/
//dll_test.cpp
#define TEST_SDK_API extern "C" __declspec(dllexport)
#include "dll_test.h"

int __stdcall add(int x, int y)
{
    return x+y;
}

 定义def文件dll_test.def

LIBRARY
EXPORTS
add @1

 2013年1月17日 在MFC调用DLL误告警问题:这个问题是由于DLL中定义了全局对象类,解决这个问题的办法是全局对象均以指针方式,则MFC就不出现内存泄漏告警了。

原文地址:https://www.cnblogs.com/qiantz/p/2642003.html