1. 创建一个新的项目
2. 新建文件 配置依赖库
配置依赖库 创建 头文件 和 cpp 导入自己的代码
3. 在pch.h 里添加自己的类
#define CLASS_DECLSPEC __declspec(dllexport) 为类的声明
其中 CLASS_DECLSPEC 要放到类 中。
// pch.h: 这是预编译标头文件。
// 下方列出的文件仅编译一次,提高了将来生成的生成性能。
// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
#ifndef PCH_H
#define PCH_H
// 添加要在此处预编译的标头
#include "framework.h"
#include <iostream>
#include <dhnetsdk.h>
#include <string.h>
#define CLASS_DECLSPEC __declspec(dllexport) // 类的声明
class CLASS_DECLSPEC DHZL
{
static void SnapRev(LLONG lLoginID, BYTE* pBuf, UINT RevLen, UINT EncodeType, DWORD CmdSerial, LDWORD dwUser);
static void DisConnectFunc(LONG lLoginID, char* pchDVRIP, LONG nDVRPort, DWORD);
public:
LLONG m_nPDLLHandle; // sdk句柄
std::string strIp = ""; // ip
int strPort = 9000; // 端口
std::string strUsername = ""; // 用户名
std::string strPassword = ""; // 密码
std::string strfilepath = ""; //文件名
// 密码
unsigned int channel = 0; // 设备channel
BOOL Init();
void Uninit();
void Outlogin();
int Login();
int Update(std::string ip, int port, std::string username, std::string password, unsigned int channel);
int Capture();
void Save_pic(BYTE* pBuf, UINT RevLen);
// 本地有这个文件才叫成功,否则是失败
int Capture(std::string filepath);
int Goto_preset(int preset);
};
#endif //PCH_H
4. 生成解决方案
运行 或者 生成。