Explorar el Código

UB530内存通信SDK

Jeff hace 5 años
padre
commit
4287fbe0a4

+ 26 - 0
UB530SDK/UB530SDK.sln

@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UB530SDK", "UB530SDK\UB530SDK.vcproj", "{885B6629-6536-4611-BCB1-0C727165DA8A}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcproj", "{602679D5-A295-4539-9D15-B8E07C2BF203}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{885B6629-6536-4611-BCB1-0C727165DA8A}.Debug|Win32.ActiveCfg = Debug|Win32
+		{885B6629-6536-4611-BCB1-0C727165DA8A}.Debug|Win32.Build.0 = Debug|Win32
+		{885B6629-6536-4611-BCB1-0C727165DA8A}.Release|Win32.ActiveCfg = Release|Win32
+		{885B6629-6536-4611-BCB1-0C727165DA8A}.Release|Win32.Build.0 = Release|Win32
+		{602679D5-A295-4539-9D15-B8E07C2BF203}.Debug|Win32.ActiveCfg = Debug|Win32
+		{602679D5-A295-4539-9D15-B8E07C2BF203}.Debug|Win32.Build.0 = Debug|Win32
+		{602679D5-A295-4539-9D15-B8E07C2BF203}.Release|Win32.ActiveCfg = Release|Win32
+		{602679D5-A295-4539-9D15-B8E07C2BF203}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

+ 139 - 0
UB530SDK/UB530SDK/MemoryComm.cpp

@@ -0,0 +1,139 @@
+#include "stdafx.h"
+#include "MemoryComm.h"
+#include "MemoryDef.h"
+
+CMemoryComm::CMemoryComm(void) :m_hLock(NULL),
+m_hFileMap(NULL),
+m_pMemory(NULL)
+{
+
+}
+
+CMemoryComm::~CMemoryComm(void)
+{
+	Close();
+	if (m_hLock != NULL)
+	{
+		CloseHandle(m_hLock);
+	}
+}
+
+
+CMemoryComm::CMemoryComm(const CMemoryComm& other)
+{
+	//if ( this != other)
+	//{
+	//	m_hLock = other.m_hLock;
+	//	m_hFileMap = other.m_hFileMap;
+	//	m_pMemory = other.m_pMemory;
+	//}
+}
+
+CMemoryComm& CMemoryComm::operator=(const CMemoryComm& other)
+{
+	// TODO: 在此处插入 return 语句
+	//if (this != other)
+	//{
+	//	m_hLock = other.m_hLock;
+	//	m_hFileMap = other.m_hFileMap;
+	//	m_pMemory = other.m_pMemory;
+	//}
+
+	return *this;
+}
+
+
+void CMemoryComm::Unmap()
+{
+	if (m_pMemory)
+	{
+		::UnmapViewOfFile(m_pMemory);
+		m_pMemory = NULL;
+	}
+}
+
+
+// 锁定共享内存
+BOOL CMemoryComm::Lock(DWORD dwTime)
+{
+	// 如果还没有创建锁就先创建一个
+	if (!m_hLock)
+	{
+		// 初始化的时候不被任何线程占用
+		m_hLock = ::CreateMutex(NULL, FALSE, MEMERY_NAME);
+		if (!m_hLock)
+			return FALSE;
+	}
+
+	// 哪个线程最先调用等待函数就最先占用这个互斥量
+	DWORD dwRet = ::WaitForSingleObject(m_hLock, dwTime);
+	return (dwRet == WAIT_OBJECT_0 || dwRet == WAIT_ABANDONED);
+}
+
+void CMemoryComm::Unlock()
+{
+	if (m_hLock)
+	{
+		::ReleaseMutex(m_hLock);
+	}
+}
+
+void CMemoryComm::Close()
+{
+	Unmap();
+
+	if (m_hFileMap)
+	{
+		::CloseHandle(m_hFileMap);
+		m_hFileMap = NULL;
+	}
+}
+
+/************************************************************************/
+/*  函数:[7/3/2018 Wang];
+/*  描述:初始化共享内存,若已创建内存则打开;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+BOOL CMemoryComm::InitMemery(DWORD dwOffset /* = 0*/)
+{
+	if (m_hFileMap == NULL)
+	{
+		// 创建共享内存;
+		m_hFileMap = ::CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, MEMERY_SIZE, MEMERY_NAME);
+		if (ERROR_ALREADY_EXISTS == GetLastError())
+		{
+			CloseHandle(m_hFileMap);
+			m_hFileMap = NULL;
+
+			// 打开共享内存;
+			m_hFileMap = ::OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, MEMERY_NAME);
+			if (!m_hFileMap)
+				return FALSE;
+		}
+	}
+
+	// 将内存映射出来;
+	if (m_pMemory == NULL)
+	{
+		ULARGE_INTEGER ui;
+		ui.QuadPart = static_cast<ULONGLONG>(dwOffset);
+		m_pMemory = ::MapViewOfFile(m_hFileMap, FILE_MAP_ALL_ACCESS, ui.HighPart, ui.LowPart, MEMERY_SIZE);
+		if (m_pMemory == NULL)
+		{
+			//ShowSystemErrorInfo(_T("映射内存失败"), GetLastError());
+			return FALSE;
+		}
+	}
+
+	return TRUE;
+}

+ 30 - 0
UB530SDK/UB530SDK/MemoryComm.h

@@ -0,0 +1,30 @@
+#ifndef __MEMORY_COMM_HEADER__
+#define __MEMORY_COMM_HEADER__
+
+#pragma once
+
+class CMemoryComm
+{
+public:
+	CMemoryComm(void);
+	~CMemoryComm(void);
+
+protected:
+	HANDLE m_hLock;
+	HANDLE m_hFileMap;
+	LPVOID m_pMemory;
+
+	CMemoryComm(const CMemoryComm& other);
+	CMemoryComm& operator = (const CMemoryComm& other);
+
+public:
+	BOOL InitMemery(DWORD dwOffset = 0);
+	void Unmap();
+	LPVOID GetMemory() const { return m_pMemory; }
+	HANDLE GetHandle() const { return m_hFileMap; }
+	BOOL Lock(DWORD dwTime);
+	void Unlock();
+	void Close();
+};
+
+#endif

+ 132 - 0
UB530SDK/UB530SDK/MemoryDef.h

@@ -0,0 +1,132 @@
+/************************************************************************/
+/*  Copyright (C), 2016-2020, [Wang], 保留所有权利;
+/*  模 块 名:内存共享C/S通信协议;
+/*  描    述:;
+/*
+/*  版    本:[V];	
+/*  作    者:[Wang];
+/*  日    期:[7/4/2018];
+/*
+/*
+/*  注    意:;
+/*
+/*  修改记录:[Wang];
+/*  修改日期:;
+/*  修改版本:;
+/*  修改内容:;
+/************************************************************************/
+#ifndef __CD750_PROTO__
+#define __CD750_PROTO__
+
+// 命令类型;
+enum CommandType {
+	SHOW_APP,
+	HIDE_APP,
+	CONNECT_DEVICE,
+	DIS_CONNECT_DEVICE,
+	START_STREAMING,
+	STOP_STREAMING,
+	STOP_CAPTUREIMAGE,
+	CAPTURE_IMAGE_COUNT,
+	CAPTURE_IMAGE_TIME,
+	CAPTURE_IMAGE_SINGLE,
+	STOP_CAPTUREAUDIO,
+	SYN_CAPTURE_AUDIO,
+	ASY_CAPTURE_AUDIO
+};
+
+// 命令头;
+typedef struct COMMANDHAED{
+	unsigned short cmdFlag;		// 命令标识符;//固定:0x7F;
+	unsigned short cmdType;		// 命令类型;
+	BOOL  cmdUser;				// 命令者:C端=false,S端=true;
+	DWORD cmdCRC32;				// 对具体命令的crc32校验;//校验耗时,暂不做;
+
+	COMMANDHAED()
+	{
+		cmdFlag = 0x7F;
+		cmdType = 0;
+		cmdUser = TRUE;
+		cmdCRC32 = 0;
+	}
+	// 拷贝构造函数;
+	COMMANDHAED(const COMMANDHAED& other)
+	{
+		if (this != &other)
+		{
+			cmdFlag = other.cmdFlag;
+			cmdType = other.cmdType;
+			cmdUser = other.cmdUser;
+			cmdCRC32 = other.cmdCRC32;
+		}
+	}
+
+	// 赋值重载函数;
+	COMMANDHAED& operator = (const COMMANDHAED& other)
+	{
+		if (this != &other)
+		{
+			cmdFlag = other.cmdFlag;
+			cmdType = other.cmdType;
+			cmdUser = other.cmdUser;
+			cmdCRC32 = other.cmdCRC32;
+		}
+
+		return *this;
+	}
+}CommandHead,*pCommandHead;
+
+// 连接设备;
+typedef struct CMD_CONECTDEVICE {
+	CommandHead cmdHead;
+	unsigned short nIndex;		// 设备索引;
+}CMD_ConnectDevice, *pCMD_ConnectDevice;
+
+// 截图;
+typedef struct CMD_CAPUTERIMAGE{
+	// 命令头;
+	CommandHead cmdHead;
+	// 图片格式;
+	unsigned short dwImageType;
+	// 持续方式;//false=以张数为单位; true以秒为单位;
+	BOOL bContinuType;	
+	// 持续时间;
+	int nKeepTime;
+	// 每秒抓取张数;
+	int nCaputerCount;
+	// 保存路径;
+	TCHAR szSaveDir[MAX_PATH];
+	// 文件名前缀;
+	TCHAR szPrefix[64];
+	// 是否自动命名;
+	BOOL IsAutoName;
+}CMD_CaputerImage,*pCMD_CaputerImage;
+
+// 视屏保存;
+typedef struct CMD_CAPUTERAUDIO {
+	// 命令头;
+	CommandHead cmdHead;
+	// 录制时长//单位毫秒;
+	DWORD dwDuration;
+	// 保存路径;
+	TCHAR szSaveDir[MAX_PATH];
+}CMD_CaputerAudio,*pCMD_CaputerAudio;
+
+// 开始/停止流命令;
+typedef struct CMD_STREAMOPT{
+	CommandHead cmdHead;
+	BOOL bStartStreaming;
+}CMD_StreamOpt, *pCMD_StreamOpt;
+
+// 返回结果;
+typedef struct CMD_RESULT{
+	CommandHead cmdHead;
+	BOOL bResult;
+}CMD_Result,*pCMD_Result;
+
+// 共享内存名称;
+#define MEMERY_NAME _T("UB530#TCL#ShareMemery")
+// 共享内存的大小;
+#define MEMERY_SIZE 1024*8	//8k;
+
+#endif // __CD750_PROTO__

+ 405 - 0
UB530SDK/UB530SDK/MemoryServer.cpp

@@ -0,0 +1,405 @@
+#include "StdAfx.h"
+#include "MemoryServer.h"
+#include <tlhelp32.h>
+#include <Shlwapi.h>
+#pragma comment(lib, "shlwapi.lib")
+
+#ifdef __TESET__
+DWORD IsAppRunning(LPCTSTR lpszAppDir)
+{
+	if (!lpszAppDir || !PathFileExists(lpszAppDir))
+		return 0;
+
+	TString strAppDir = lpszAppDir;
+	int nIndex = strAppDir.find_last_of(_T('\\'));
+	if (nIndex != TString::npos )
+		strAppDir = strAppDir.substr(nIndex+1);
+
+	DWORD dwProcessID = 0;
+	PROCESSENTRY32 pe32 = { 0 };
+
+	HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+	if (hProcessSnap == NULL)
+	{
+		ShowSystemErrorInfo(_T("获取进程快照失败"),GetLastError());
+		return 0;
+	}
+	pe32.dwSize = sizeof(PROCESSENTRY32);
+
+	if (Process32First(hProcessSnap, &pe32))
+	{
+		do
+		{
+			// szExeFile只是文件名,不知道是否只有win10才这样;
+			if (_tcsicmp(strAppDir.c_str(), pe32.szExeFile) == 0)
+			{
+				dwProcessID = pe32.th32ProcessID;
+				break;
+			}
+		} while (Process32Next(hProcessSnap, &pe32));
+	}
+	CloseHandle(hProcessSnap);
+
+	return dwProcessID;
+}
+
+bool CloseApp(DWORD dwAppId)
+{
+	if ( dwAppId == 0 )
+		return false;
+
+	HANDLE hProcess = ::OpenProcess(PROCESS_ALL_ACCESS, TRUE, dwAppId);
+	if (hProcess == NULL)
+	{
+		ShowSystemErrorInfo(_T("打开进程失败"),GetLastError());
+		return false;
+	}
+
+	DWORD dwError;
+	if (!TerminateProcess(hProcess, 0))
+	{
+		dwError = GetLastError();
+		CloseHandle(hProcess);
+		hProcess = NULL;
+		return false;
+	}
+
+	// 等待进程结束响应;
+	if (WAIT_OBJECT_0 != WaitForSingleObject(hProcess, INFINITE))
+	{
+		CloseHandle(hProcess);
+		return false;
+	}
+
+	CloseHandle(hProcess);
+	hProcess = NULL;
+
+	return true;
+}
+
+#endif
+
+CMemoryServer::CMemoryServer(void)
+{
+}
+
+CMemoryServer::~CMemoryServer(void)
+{
+}
+
+
+BOOL CMemoryServer::GetResult()
+{
+	// 获取返回结果;
+	Sleep(50); // 等待客户端响应;
+	CMD_Result result;
+	do 
+	{
+		Lock(INFINITE);
+		memcpy(&result, m_pMemory, sizeof(CMD_Result));
+		Unlock();
+		//Sleep(100);
+	} while (result.cmdHead.cmdUser != FALSE);
+	//WriteTextLog("result:%d",result.bResult);
+
+	return result.bResult;
+}
+
+BOOL CMemoryServer::StartApp(LPCTSTR lpAppDir)
+{
+	if (!lpAppDir || !PathFileExists(lpAppDir))
+		return FALSE;
+
+	if ( IsAppRunning(lpAppDir) != 0)
+		return TRUE;
+
+	// 启动应用程序;
+	//ShellExecute(NULL, "open", pszExePath, NULL, NULL, SW_SHOWNORMAL);
+	SHELLEXECUTEINFO sei;
+	memset(&sei, 0, sizeof(SHELLEXECUTEINFO));
+	sei.cbSize = sizeof(SHELLEXECUTEINFO);
+	sei.hwnd = NULL;
+	// 普通打开方式:open;若想以管理员身份运行:runas
+	sei.lpVerb = _T("runas");
+	//sei.fMask = SEE_MASK_NOCLOSEPROCESS;//不设置,则使用默认值;
+	sei.lpFile = lpAppDir;
+	sei.lpParameters = NULL;
+	sei.lpDirectory = NULL;
+	sei.nShow = SW_SHOWNORMAL;
+	sei.hInstApp = NULL;
+
+	if ( !ShellExecuteEx(&sei) )
+	{
+		DWORD dw = GetLastError();
+		return FALSE;
+	}
+
+	if (sei.hProcess)
+		CloseHandle(sei.hProcess);
+
+	return TRUE;
+}
+
+BOOL CMemoryServer::ShowApp()
+{
+	Lock(INFINITE);
+	// 命令;
+	CommandHead cmdHead;
+	cmdHead.cmdFlag = 0x7F;
+	cmdHead.cmdType = SHOW_APP;
+	cmdHead.cmdUser = TRUE;
+	cmdHead.cmdCRC32 = 0;
+
+	// 清空内存;
+	memset(m_pMemory, 0, MEMERY_SIZE);
+	// 写入共享内存;
+	memcpy(m_pMemory, &cmdHead, sizeof(CommandHead));
+	Unlock();
+
+	return TRUE;
+}
+
+BOOL CMemoryServer::HideApp()
+{
+	Lock(INFINITE);
+	// 命令;
+	CommandHead cmdHead;
+	cmdHead.cmdFlag = 0x7F;
+	cmdHead.cmdType = HIDE_APP;
+	cmdHead.cmdUser = TRUE;
+	cmdHead.cmdCRC32 = 0;
+
+	// 清空内存;
+	memset(m_pMemory, 0, MEMERY_SIZE);
+	// 写入共享内存;
+	memcpy(m_pMemory, &cmdHead, sizeof(CommandHead));
+	Unlock();
+
+	return TRUE;
+}
+
+BOOL CMemoryServer::ConnectDevice()
+{
+	Lock(INFINITE);
+	// 命令;
+	CMD_ConnectDevice cmd;
+	cmd.cmdHead.cmdFlag = 0x7F;
+	cmd.cmdHead.cmdType = CONNECT_DEVICE;
+	cmd.cmdHead.cmdUser = TRUE;
+	cmd.cmdHead.cmdCRC32 = 0;
+
+	// 清空内存;
+	memset(m_pMemory, 0, MEMERY_SIZE);
+	// 写入共享内存;
+	memcpy(m_pMemory, &cmd, sizeof(CMD_ConnectDevice));
+	Unlock();
+
+	return GetResult();
+}
+
+BOOL CMemoryServer::DisconnectDevice()
+{
+	Lock(INFINITE);
+	// 命令;
+	CMD_ConnectDevice cmd;
+	cmd.cmdHead.cmdFlag = 0x7F;
+	cmd.cmdHead.cmdType = DIS_CONNECT_DEVICE;
+	cmd.cmdHead.cmdUser = TRUE;
+	cmd.cmdHead.cmdCRC32 = 0;
+
+	// 清空内存;
+	memset(m_pMemory, 0, MEMERY_SIZE);
+	// 写入共享内存;
+	memcpy(m_pMemory, &cmd, sizeof(CMD_ConnectDevice));
+	Unlock();
+
+	return GetResult();
+}
+
+BOOL CMemoryServer::StreamOpt(BOOL bStartStreaming)
+{
+	Lock(INFINITE);
+	// 命令;
+	CMD_StreamOpt cmd;
+	cmd.cmdHead.cmdFlag = 0x7F;
+	cmd.cmdHead.cmdType = bStartStreaming?START_STREAMING:STOP_STREAMING;
+	cmd.cmdHead.cmdUser = TRUE;
+	cmd.cmdHead.cmdCRC32 = 0;
+	cmd.bStartStreaming = bStartStreaming;
+
+	// 清空内存;
+	memset(m_pMemory, 0, MEMERY_SIZE);
+	// 写入共享内存;
+	memcpy(m_pMemory, &cmd, sizeof(CMD_StreamOpt));
+	Unlock();
+
+	return GetResult();
+}
+
+BOOL CMemoryServer::CaptureImageByCount( int nKeepTime, LPCTSTR lpszSaveDir, LPCTSTR lpszPrefix,unsigned short dwImageType )
+{
+	Lock(INFINITE);
+	// 命令;
+	CMD_CaputerImage cmd;
+	cmd.cmdHead.cmdFlag = 0x7F;
+	cmd.cmdHead.cmdType = CAPTURE_IMAGE_COUNT;
+	cmd.cmdHead.cmdUser = TRUE;
+	cmd.cmdHead.cmdCRC32 = 0;
+	cmd.dwImageType = dwImageType;
+	
+	cmd.bContinuType = FALSE;
+	cmd.nKeepTime = nKeepTime;
+	cmd.nCaputerCount = 0;
+	_stprintf_s(cmd.szSaveDir, _T("%s"), lpszSaveDir == NULL ? _T("") : lpszSaveDir);
+	_stprintf_s(cmd.szPrefix, _T("%s"), lpszPrefix == NULL ? _T("CD750") : lpszPrefix);
+	Replacepath(cmd.szSaveDir);
+
+	// 清空内存;
+	memset(m_pMemory, 0, MEMERY_SIZE);
+	// 写入共享内存;
+	memcpy(m_pMemory, &cmd, sizeof(CMD_CaputerImage));
+	Unlock();
+
+	return GetResult();
+}
+
+BOOL CMemoryServer::CaptureSingleImage( LPCTSTR lpszSaveDir, unsigned short dwImageType, BOOL IsAutoName )
+{
+	Lock(INFINITE);
+	// 命令;
+	CMD_CaputerImage cmd;
+	cmd.cmdHead.cmdFlag = 0x7F;
+	cmd.cmdHead.cmdType = CAPTURE_IMAGE_SINGLE;
+	cmd.cmdHead.cmdUser = TRUE;
+	cmd.cmdHead.cmdCRC32 = 0;
+	cmd.dwImageType = dwImageType;
+	
+	cmd.IsAutoName = IsAutoName;
+	cmd.nKeepTime = 1;
+	cmd.nCaputerCount = 0;
+	_stprintf_s(cmd.szSaveDir, _T("%s"), lpszSaveDir == NULL ? _T("") : lpszSaveDir);
+	Replacepath(cmd.szSaveDir);
+
+	// 清空内存;
+	memset(m_pMemory, 0, MEMERY_SIZE);
+	// 写入共享内存;
+	memcpy(m_pMemory, &cmd, sizeof(CMD_CaputerImage));
+	Unlock();
+
+	return GetResult();
+}
+
+BOOL CMemoryServer::CaptureImageByTime( int nKeepTime, int nCaputerCount, LPCTSTR lpszSaveDir, LPCTSTR lpszPrefix, unsigned short dwImageType)
+{
+	Lock(INFINITE);
+	// 命令;
+	CMD_CaputerImage cmd;
+	cmd.cmdHead.cmdFlag = 0x7F;
+	cmd.cmdHead.cmdType = CAPTURE_IMAGE_TIME;
+	cmd.cmdHead.cmdUser = TRUE;
+	cmd.cmdHead.cmdCRC32 = 0;
+	cmd.dwImageType = dwImageType;
+	
+	cmd.bContinuType = TRUE;
+	cmd.nKeepTime = nKeepTime;
+	cmd.nCaputerCount = nCaputerCount;
+	_stprintf_s(cmd.szSaveDir, _T("%s"), lpszSaveDir == NULL ? _T("") : lpszSaveDir);
+	_stprintf_s(cmd.szPrefix, _T("%s"), lpszPrefix == NULL ? _T("CD750") : lpszPrefix);
+	Replacepath(cmd.szSaveDir);
+
+	// 清空内存;
+	memset(m_pMemory, 0, MEMERY_SIZE);
+	// 写入共享内存;
+	memcpy(m_pMemory, &cmd, sizeof(CMD_CaputerImage));
+	Unlock();
+
+	return GetResult();
+}
+
+BOOL CMemoryServer::StopCaptureImage()
+{
+	Lock(INFINITE);
+	// 命令;
+	CommandHead cmdHead;
+	cmdHead.cmdFlag = 0x7F;
+	cmdHead.cmdType = STOP_CAPTUREIMAGE;
+	cmdHead.cmdUser = TRUE;
+	cmdHead.cmdCRC32 = 0;
+
+	// 清空内存;
+	memset(m_pMemory, 0, MEMERY_SIZE);
+	// 写入共享内存;
+	memcpy(m_pMemory, &cmdHead, sizeof(CommandHead));
+	Unlock();
+
+	// 等待结果;
+	// 未实现;
+
+	return TRUE;
+}
+
+BOOL CMemoryServer::SynCaptureAudio(LPCTSTR lpszSaveDir)
+{
+	Lock(INFINITE);
+	// 命令;
+	CMD_CaputerAudio cmd;
+	cmd.cmdHead.cmdFlag = 0x7F;
+	cmd.cmdHead.cmdType = SYN_CAPTURE_AUDIO;
+	cmd.cmdHead.cmdUser = TRUE;
+	cmd.cmdHead.cmdCRC32 = 0;
+	cmd.dwDuration = 0;
+	_stprintf_s(cmd.szSaveDir, _T("%s"), lpszSaveDir);
+	Replacepath(cmd.szSaveDir);
+
+	// 清空内存;
+	memset(m_pMemory, 0, MEMERY_SIZE);
+	// 写入共享内存;
+	memcpy(m_pMemory, &cmd, sizeof(CMD_CaputerAudio));
+	Unlock();
+
+	return GetResult();
+}
+
+BOOL CMemoryServer::AsyCaptureAudio(DWORD dwDuration, LPCTSTR lpszSaveDir)
+{
+	Lock(INFINITE);
+	// 命令;
+	CMD_CaputerAudio cmd;
+	cmd.cmdHead.cmdFlag = 0x7F;
+	cmd.cmdHead.cmdType = ASY_CAPTURE_AUDIO;
+	cmd.cmdHead.cmdUser = TRUE;
+	cmd.cmdHead.cmdCRC32 = 0;
+	cmd.dwDuration = dwDuration;
+	_stprintf_s(cmd.szSaveDir, _T("%s"), lpszSaveDir);
+	Replacepath(cmd.szSaveDir);
+
+	// 清空内存;
+	memset(m_pMemory, 0, MEMERY_SIZE);
+	// 写入共享内存;
+	memcpy(m_pMemory, &cmd, sizeof(CMD_CaputerAudio));
+	Unlock();
+
+	return GetResult();
+}
+
+BOOL CMemoryServer::StopCaptureAudio()
+{
+	Lock(INFINITE);
+	// 命令;
+	CommandHead cmdHead;
+	cmdHead.cmdFlag = 0x7F;
+	cmdHead.cmdType = STOP_CAPTUREAUDIO;
+	cmdHead.cmdUser = TRUE;
+	cmdHead.cmdCRC32 = 0;
+
+	// 清空内存;
+	memset(m_pMemory, 0, MEMERY_SIZE);
+	// 写入共享内存;
+	memcpy(m_pMemory, &cmdHead, sizeof(CommandHead));
+	Unlock();
+
+	// 等待结果;
+	// 未实现;
+
+	return TRUE;
+}

+ 86 - 0
UB530SDK/UB530SDK/MemoryServer.h

@@ -0,0 +1,86 @@
+#ifndef __MEMORY_SERVER__
+#define __MEMORY_SERVER__
+
+#pragma once
+
+#include "MemoryDef.h"
+#include "MemoryComm.h"
+
+class CMemoryServer:public CMemoryComm
+{
+public:
+	CMemoryServer(void);
+	~CMemoryServer(void);
+
+	BOOL StartApp(LPCTSTR lpAppDir);
+	BOOL StopApp();
+	BOOL ShowApp();
+	BOOL HideApp();
+	BOOL ConnectDevice();
+	BOOL DisconnectDevice();
+	BOOL StreamOpt(BOOL bStartStreaming = TRUE);
+	BOOL CaptureImageByCount(		
+		int nKeepTime,						// 持续时间;
+		LPCTSTR lpszSaveDir,				// 保存路径;
+		LPCTSTR lpszPrefix,					// 文件前缀;
+		unsigned short dwImageType = 2		// 相片格式;
+		);
+	BOOL CaptureSingleImage(		
+		LPCTSTR lpszSaveDir,				// 保存路径;
+		unsigned short dwImageType = 2,		// 相片格式;
+		BOOL IsAutoName = FALSE
+		);
+	BOOL CaptureImageByTime(
+		int nKeepTime,						// 持续时间;
+		int nCaputerCount,					// 每秒抓取张数;
+		LPCTSTR lpszSaveDir,				// 保存路径;
+		LPCTSTR lpszPrefix,					// 文件前缀;
+		unsigned short dwImageType = 2		// 相片格式;
+		);
+	BOOL StopCaptureImage();
+	BOOL SynCaptureAudio(LPCTSTR lpszSaveDir);
+	BOOL AsyCaptureAudio(DWORD dwDuration, LPCTSTR lpszSaveDir);
+	BOOL StopCaptureAudio();
+
+	BOOL GetResult();
+	inline void Replacepath2(char *p){
+		while( *p != '\0' )
+		{
+			if (*p == '/') *p = '\\';
+			p++;
+		}
+	}
+
+	inline void Replacepath(char *p){
+		int i = 0;
+		char *pold = p;
+		char szpath[MAX_PATH] = {'\0'};
+		while( *p != '\0' )
+		{
+			if (szpath[i-1] == '\\' && ('\\' == *p || '/' == *p))
+			{
+				if (i == 1)
+				{// 如果是共享目录;
+					if (*p == '/') 
+						*p = '\\';
+					szpath[i] = *p;
+					i++;
+				}
+				p++;
+				continue;
+			}
+
+			if (*p == '/') 
+				*p = '\\';
+			szpath[i] = *p;
+			p++;i++;
+		}
+
+		memcpy(pold, szpath, i);
+		pold += i;
+		*pold = '\0';
+	}
+
+};
+
+#endif

+ 37 - 0
UB530SDK/UB530SDK/ReadMe.txt

@@ -0,0 +1,37 @@
+========================================================================
+    动态链接库:UB530SDK 项目概述
+========================================================================
+
+应用程序向导已为您创建了此 UB530SDK DLL。
+
+本文件概要介绍组成 UB530SDK 应用程序的
+的每个文件的内容。
+
+
+UB530SDK.vcproj
+    这是使用应用程序向导生成的 VC++ 项目的主项目文件,
+    其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
+
+UB530SDK.cpp
+    这是主 DLL 源文件。
+
+	此 DLL 在创建时不导出任何符号。因此,在生成此 DLL 时
+	将不会产生 .lib 文件。如果希望此项目
+	成为其他某个项目的项目依赖项,则需要
+	添加代码以从 DLL 导出某些符号,
+	以便产生一个导出库,或者,也可以在项目“属性页”对话框中的
+	“链接器”文件夹中,将“常规”属性页上的
+	“忽略输入库”属性设置为“是”。
+
+/////////////////////////////////////////////////////////////////////////////
+其他标准文件:
+
+StdAfx.h, StdAfx.cpp
+    这些文件用于生成名为 UB530SDK.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
+
+/////////////////////////////////////////////////////////////////////////////
+其他注释:
+
+应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
+
+/////////////////////////////////////////////////////////////////////////////

+ 516 - 0
UB530SDK/UB530SDK/UB530SDK.cpp

@@ -0,0 +1,516 @@
+// UB530SDK.cpp : 定义 DLL 应用程序的导出函数。
+//
+
+#include "stdafx.h"
+#include "Python.h"
+#include "MemoryServer.h"
+
+CMemoryServer g_ub530;
+PyObject *g_list = NULL;
+/************************************************************************/
+/*  函数:[7/4/2018 Wang];
+/*  描述:进程是否在运行;
+/*  参数:;
+/*  	[IN] :执行文件路径;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:成功返回进程ID(!= 0);
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+static PyObject* IsAppRunning(PyObject *self, PyObject *args)
+{
+	// 应用程序路径;
+	const char* pszExePath = NULL;
+	if (!PyArg_ParseTuple(args, "s", &pszExePath))
+		return NULL;
+
+	return Py_BuildValue("i", IsAppRunning(pszExePath));
+}
+
+/************************************************************************/
+/*  函数:[7/2/2018 Wang];
+/*  描述:启动进程;
+/*  参数:;
+/*  	[IN] :执行文件完整路径,并且默认打开设备索引值为0的设备;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:成功返回1,失败返回0;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+static PyObject* StartApp(PyObject *self, PyObject *args)
+{
+	// 应用程序路径;
+	const char* pszExePath = NULL;
+	if (!PyArg_ParseTuple(args, "s", &pszExePath))
+		return NULL;
+
+	// 参数有效性判断;
+	if (!pszExePath || !PathFileExists(pszExePath))
+		return Py_BuildValue("b",0);
+
+	// 进程是否存在;
+	_stprintf_s(g_szAppDir, _T("%s"), pszExePath);
+	if ( (g_dwAppId = IsAppRunning(g_szAppDir)) != 0)
+		return Py_BuildValue("b",1);
+
+	// 启动应用程序;
+	//ShellExecute(NULL, "open", pszExePath, NULL, NULL, SW_SHOWNORMAL);
+	SHELLEXECUTEINFO sei;
+	memset(&sei, 0, sizeof(SHELLEXECUTEINFO));
+	sei.cbSize = sizeof(SHELLEXECUTEINFO);
+	sei.hwnd = NULL;
+	// 普通打开方式:open;若想以管理员身份运行:runas
+	sei.lpVerb = _T("runas");
+	//sei.fMask = SEE_MASK_NOCLOSEPROCESS;//不设置,则使用默认值;
+	sei.lpFile = g_szAppDir;
+	sei.lpParameters = NULL;
+	sei.lpDirectory = NULL;
+	sei.nShow = SW_SHOWNORMAL;
+	sei.hInstApp = NULL;
+
+	if ( !ShellExecuteEx(&sei) )
+	{
+		DWORD dw = GetLastError();
+		return Py_BuildValue("b",0);
+	}
+
+	if (sei.hProcess)
+		CloseHandle(sei.hProcess);
+
+	// 打开索引为0的设备;
+	// 待实现;
+
+	return Py_BuildValue("b",1);
+}
+
+/************************************************************************/
+/*  函数:[7/2/2018 Wang];
+/*  描述:关闭进程;
+/*  参数:;
+/*  返回:成功结束进程返回1,失败返回0;
+/*  注意:Win7以上系统,如果宿主程序不是以管理权限运行,是无权附加进程并关闭进程;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+static PyObject* StopApp(PyObject *self, PyObject *args)
+{
+	// 结束进程;
+#if 1
+	if ( (g_dwAppId = IsAppRunning(g_szAppDir)) != 0)
+	{
+		if ( !CloseApp(g_dwAppId) )
+			return Py_BuildValue("b",0);
+	}
+#else
+	// 调用App的Close函数;
+#endif
+
+	return Py_BuildValue("b",1);	// 返回None;
+}
+
+/************************************************************************/
+/*  函数:[7/2/2018 Wang];
+/*  描述:连接设备,默认连接索引为0的设备;
+/*  参数:;
+/*  	[IN] :设备索引值(从0开始,默认值为0);
+/*  返回:void;
+/*  注意:连接设备需要响应时间,测试结果为大概3秒;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+static PyObject* ConnectDevice(PyObject *self, PyObject *args)
+{
+	BOOL bRet = g_ub530.ConnectDevice();
+	return Py_BuildValue("b", bRet);
+}
+
+/************************************************************************/
+/*  函数:[7/2/2018 Wang];
+/*  描述:断开设备,默认索引为0的设备;
+/*  参数:;
+/*  	[IN] :设备索引值(从0开始,默认值为0);
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+static PyObject* DisconnectDevice(PyObject *self, PyObject *args)
+{
+	BOOL bRet = g_ub530.DisconnectDevice();
+	return Py_BuildValue("b", bRet);
+}
+
+/************************************************************************/
+/*  函数:[7/2/2018 Wang];
+/*  描述:开始/停止 流;
+/*  参数:;
+/*  	[IN] :true开始,false停止;
+/*  返回:void;
+/*  注意:操作设备需要响应时间,测试结果为大概3秒;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+static PyObject* StreamOption(PyObject *self, PyObject *args)
+{
+	BOOL bStartStreaming = FALSE;
+	if (!PyArg_ParseTuple(args, "b", &bStartStreaming))
+		return NULL;
+
+	BOOL bRet = g_ub530.StreamOpt(bStartStreaming);
+	return Py_BuildValue("b", bRet);
+}
+
+/************************************************************************/
+/*  函数:[7/2/2018 Wang];
+/*  描述:显示窗口;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+static PyObject* ShowApp(PyObject *self, PyObject *args)
+{
+	g_ub530.ShowApp();
+	return Py_BuildValue("");	// 返回None;
+}
+
+/************************************************************************/
+/*  函数:[7/2/2018 Wang];
+/*  描述:隐藏窗口;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+static PyObject* HideApp(PyObject *self, PyObject *args)
+{
+	g_ub530.HideApp();
+	return Py_BuildValue("");	// 返回None;
+}
+
+/************************************************************************/
+/*  函数:[7/2/2018 Wang];
+/*  描述:抓图,持续方式以张数为单位;
+/*  参数:;
+/*  	[IN] :设备索引(从0开始);
+/*  	[IN] :图片保存路径;
+/*  	[IN] :图片保存格式,默认为PNG;
+/*  	[IN] :包括叠加内容,默认true;
+/*  	[IN-4] :采集区域,上、下、左、右4个参数;
+/*  	[IN] :截图张数,默认1;
+/*  返回:void;
+/*  注意:接口返回调用成功,并非表明完成截图,只是表示设备完成指令响应,并未完成截图工作;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+static PyObject* CaptureImageByCount(PyObject *self, PyObject *args)
+{
+	// 图片格式;
+	unsigned short dwImageType = 3;
+	// 叠加内容;
+	BOOL bOverlayMix = TRUE;
+	// 采集区域;
+	int nTop = 0, nLeft = 0, nRight = 0, nBottom = 0;
+	// 持续时间;
+	int nKeepTime = 10;
+	// 保存路径;
+	const char* lpszSaveDir = NULL;
+	// 文件前缀;
+	const char* lpszPrefix = NULL;
+	if (!PyArg_ParseTuple(args, "issh", &nKeepTime, &lpszSaveDir, &lpszPrefix, &dwImageType))
+		return NULL;
+
+	BOOL bRet = g_ub530.CaptureImageByCount( nKeepTime, lpszSaveDir, lpszPrefix, dwImageType);
+
+	return Py_BuildValue("b", bRet);
+}
+
+/************************************************************************/
+/*  函数:[7/2/2018 Wang];
+/*  描述:单张抓图,持续方式以张数为单位;
+/*  参数:;
+/*  	[IN] :设备索引(从0开始);
+/*  	[IN] :图片保存路径;
+/*  	[IN] :图片保存格式,默认为PNG;
+/*  	[IN] :包括叠加内容,默认true;
+/*  	[IN-4] :采集区域,上、下、左、右4个参数;
+/*  	[IN] :截图张数,默认1;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+static PyObject* CaptureSingleImage(PyObject *self, PyObject *args)
+{
+	// 图片格式;
+	unsigned short dwImageType = 3;
+	// 叠加内容;
+	BOOL bOverlayMix = TRUE;
+	// 采集区域;
+	int nTop = 0, nLeft = 0, nRight = 0, nBottom = 0;
+	// 持续时间;
+	int nKeepTime = 10;
+	// 保存路径;
+	const char* lpszSaveDir = NULL;
+	if (!PyArg_ParseTuple(args, "sh", &lpszSaveDir, &dwImageType))
+		return NULL;
+
+	BOOL bRet = g_ub530.CaptureSingleImage(lpszSaveDir, dwImageType);
+
+	return Py_BuildValue("b", bRet);
+}
+
+/************************************************************************/
+/*  函数:[7/2/2018 Wang];
+/*  描述:抓图,持续方式以秒为单位;
+/*  参数:;
+/*  	[IN] :设备索引(从0开始);
+/*  	[IN] :图片保存路径;
+/*  	[IN] :图片保存格式,默认为PNG;
+/*  	[IN] :包括叠加内容,默认true;
+/*  	[IN-4] :采集区域,上、下、左、右4个参数;
+/*  	[IN] :持续时间,默认1000ms;
+/*  	[IN] :每秒抓取张数,默认10张;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+static PyObject* CaptureImageByTime(PyObject *self, PyObject *args)
+{
+	// 图片格式;
+	unsigned short dwImageType = 3;
+	// 叠加内容;
+	BOOL bOverlayMix = TRUE;
+	// 采集区域;
+	int nTop = 0, nLeft = 0, nRight = 0, nBottom = 0;
+	// 持续时间;
+	int nKeepTime = 10;
+	// 每秒抓取张数;
+	int nCaputerCount = 0;
+	// 保存路径;
+	const char* lpszSaveDir = NULL;
+	// 文件前缀;
+	const char* lpszPrefix = NULL;
+	if (!PyArg_ParseTuple(args, "iissh", &nKeepTime, &nCaputerCount, &lpszSaveDir, &lpszPrefix, &dwImageType))
+		return NULL;
+
+	BOOL bRet = g_ub530.CaptureImageByTime(nKeepTime, nCaputerCount, lpszSaveDir, lpszPrefix, dwImageType);
+
+	return Py_BuildValue("b", bRet);
+}
+
+/************************************************************************/
+/*  函数:[7/2/2018 Wang];
+/*  描述:停止截图,暂未使用;
+/*  参数:;
+/*  	[IN] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+static PyObject* StopCaptureImage(PyObject *self, PyObject *args)
+{
+	g_ub530.StopCaptureImage();
+	return Py_BuildValue("");	// 返回None;
+}
+
+/************************************************************************/
+/*  函数:[7/2/2018 Wang];
+/*  描述:同步视频录制;
+/*  参数:;
+/*  	[IN] :视屏的保存路径;
+/*  	[IN] :录制时间长度,以秒为单位(约值);
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+static PyObject* StartCaptureAudio(PyObject *self, PyObject *args)
+{
+	// 保存路径;
+	const char* lpszSaveDir = NULL;
+	if (!PyArg_ParseTuple(args, "s", &lpszSaveDir))
+		return NULL;
+
+	BOOL bRet = g_ub530.SynCaptureAudio(lpszSaveDir);
+
+	return Py_BuildValue("b", bRet);
+}
+
+/************************************************************************/
+/*  函数:[7/2/2018 Wang];
+/*  描述:停止录制视频;
+/*  参数:;
+/*  	[IN] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+static PyObject* StopCaptureAudio(PyObject *self, PyObject *args)
+{
+	g_ub530.StopCaptureAudio();
+	return Py_BuildValue("");	// 返回None;
+}
+
+/************************************************************************/
+/*  函数:[7/2/2018 Wang];
+/*  描述:异步视频录制;
+/*  参数:;
+/*  	[IN] :视屏的保存路径;
+/*  	[IN] :录制时间长度,以秒为单位(约值);
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+static PyObject* AsyCaptureAudio(PyObject *self, PyObject *args)
+{
+	// 持续时间;
+	DWORD dwKeepTime = 10;
+	// 保存路径;
+	const char* lpszSaveDir = NULL;
+	if (!PyArg_ParseTuple(args, "ls", &dwKeepTime, &lpszSaveDir))
+		return NULL;
+
+	BOOL bRet = g_ub530.AsyCaptureAudio(dwKeepTime, lpszSaveDir);
+
+	return Py_BuildValue("b", bRet);
+}
+
+/************************************************************************/
+/*  函数:[8/13/2018 jianfeng1.wang];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+static PyObject* GetCaptureImageList(PyObject *self, PyObject *args)
+{
+	// 保存路径;
+	const char* lpszImgDir = NULL;
+	if (!PyArg_ParseTuple(args, "s", &lpszImgDir))
+		return NULL;
+
+	vector<TString> files;
+	findfile(lpszImgDir, files);
+
+	if (g_list != NULL)
+	{
+		Py_DECREF(g_list);
+		g_list = NULL;
+	}
+
+	int i = 0;
+	g_list = PyList_New(0);
+	for (vector<TString>::iterator it = files.begin(); it != files.end(); it++)
+	{
+		PyList_Append(g_list, PyString_FromString(it->c_str()));
+	}
+
+	return g_list;
+}
+
+// 描述方法,暴露给python的函数;
+static PyMethodDef UB530_Methods[] ={
+	{"IsAppRunning",IsAppRunning,METH_VARARGS,"程序是否在运行"},
+	{"StartApp", StartApp, METH_VARARGS, "启动进程"},
+	{"StopApp", StopApp, METH_VARARGS, "关闭进程"},
+	{"ConnectDevice", ConnectDevice, METH_VARARGS, "连接设备"},
+	{"DisconnectDevice", DisconnectDevice, METH_VARARGS, "断开设备"},
+	{"StreamOption",StreamOption,METH_VARARGS,"流操作"},
+	{"ShowApp", ShowApp, METH_VARARGS, "显示窗口"},
+	{"HideApp", HideApp, METH_VARARGS, "隐藏窗口"},
+	{"CaptureImageByCount", CaptureImageByCount, METH_VARARGS, "以张数为单位抓图"},
+	{"CaptureImageByTime", CaptureImageByTime, METH_VARARGS, "以时间为单位抓图"},
+	{"CaptureSingleImage", CaptureSingleImage, METH_VARARGS, "单张抓图"},
+	{"StopCaptureImage", StopCaptureImage, METH_VARARGS, "停止抓图"},
+	{"StartCaptureAudio", StartCaptureAudio, METH_VARARGS, "同步视屏录制"},
+	{"StopCaptureAudio", StopCaptureAudio, METH_VARARGS, "同步视屏录制"},
+	{"AsyCaptureAudio", AsyCaptureAudio, METH_VARARGS, "异步视屏录制"},
+	{"GetCaptureImageList", GetCaptureImageList, METH_VARARGS, "返回目录文件列表"},
+	{NULL,NULL}
+};
+
+// 初始模块;//格式:init<模块名称>
+PyMODINIT_FUNC initUB530SDK()
+{
+	// 初始化共享内存;
+	g_ub530.InitMemery();
+	// 进程提权;
+	if ( !GetDebugPriv() )
+		WriteTextLog(_T("提权失败"));
+	// 初始化pyd函数列表;
+	PyObject *m,*d;
+	m = Py_InitModule("UB530SDK", UB530_Methods);
+	d = PyModule_GetDict(m);
+}
+
+

+ 109 - 0
UB530SDK/UB530SDK/UB530SDK.rc

@@ -0,0 +1,109 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// 中文(中华人民共和国) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
+#ifdef _WIN32
+LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
+#pragma code_page(936)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE 
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE 
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE 
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+#ifdef _AUTOVERSION_
+	FILEVERSION 1, 0, 0, $WCREV$
+#else
+	FILEVERSION 1, 0, 0, 1
+#endif
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "080404b0"
+        BEGIN
+            VALUE "FileDescription", "UB530SDK 动态链接库"
+#ifdef _AUTOVERSION_
+			VALUE "FileVersion", "1.0.0.$WCREV$"
+#else
+			VALUE "FileVersion", "1.0.0.1"
+#endif
+            VALUE "InternalName", "UB530SDK"
+            VALUE "LegalCopyright", "Copyright (C) 2019"
+            VALUE "OriginalFilename", "UB530SDK.dll"
+            VALUE "ProductName", "UB530SDK 动态链接库"
+            VALUE "ProductVersion", "1, 0, 0, 1"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x804, 1200
+    END
+END
+
+#endif    // 中文(中华人民共和国) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+

+ 281 - 0
UB530SDK/UB530SDK/UB530SDK.vcproj

@@ -0,0 +1,281 @@
+<?xml version="1.0" encoding="gb2312"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="UB530SDK"
+	ProjectGUID="{885B6629-6536-4611-BCB1-0C727165DA8A}"
+	RootNamespace="UB530SDK"
+	Keyword="Win32Proj"
+	TargetFrameworkVersion="196613"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="..\..\..\..\bin\$(ProjectName)"
+			IntermediateDirectory="$(OutDir)\$(ProjectName)\$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="C:\Python27\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;UB530SDK_EXPORTS"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="2"
+				WarningLevel="3"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="C:\Python27\libs"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="..\..\..\..\bin\$(ProjectName)"
+			IntermediateDirectory="$(OutDir)\$(ProjectName)\$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="2"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+				CommandLine="subwcrev.exe $(SolutionDir) $(ProjectDir)$(ProjectName).rc $(ProjectDir)$(ProjectName).rc_"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				EnableIntrinsicFunctions="true"
+				AdditionalIncludeDirectories="C:\Python27\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;UB530SDK_EXPORTS"
+				RuntimeLibrary="2"
+				EnableFunctionLevelLinking="true"
+				UsePrecompiledHeader="2"
+				WarningLevel="3"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+				CommandLine="rc.exe /l 0x409 /fo &quot;$(IntDir)\$(ProjectName).res&quot; /d &quot;_AUTOVERSION_&quot; /d &quot;_AFXDLL&quot; &quot;$(ProjectDir)$(ProjectName).rc_&quot;"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="C:\Python27\libs"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Ô´Îļþ"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath=".\dllmain.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="0"
+						CompileAsManaged="0"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="0"
+						CompileAsManaged="0"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath=".\MemoryComm.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\MemoryServer.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\stdafx.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath=".\UB530SDK.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Í·Îļþ"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath=".\MemoryComm.h"
+				>
+			</File>
+			<File
+				RelativePath=".\MemoryDef.h"
+				>
+			</File>
+			<File
+				RelativePath=".\MemoryServer.h"
+				>
+			</File>
+			<File
+				RelativePath=".\resource.h"
+				>
+			</File>
+			<File
+				RelativePath=".\stdafx.h"
+				>
+			</File>
+			<File
+				RelativePath=".\targetver.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="×ÊÔ´Îļþ"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+			<File
+				RelativePath=".\UB530SDK.rc"
+				>
+			</File>
+		</Filter>
+		<File
+			RelativePath=".\ReadMe.txt"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

+ 19 - 0
UB530SDK/UB530SDK/dllmain.cpp

@@ -0,0 +1,19 @@
+// dllmain.cpp : 定义 DLL 应用程序的入口点。
+#include "stdafx.h"
+
+BOOL APIENTRY DllMain( HMODULE 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;
+}
+

+ 14 - 0
UB530SDK/UB530SDK/resource.h

@@ -0,0 +1,14 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by UB530SDK.rc
+
+// жÔÏóµÄÏÂÒ»×éĬÈÏÖµ
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        101
+#define _APS_NEXT_COMMAND_VALUE         40001
+#define _APS_NEXT_CONTROL_VALUE         1001
+#define _APS_NEXT_SYMED_VALUE           101
+#endif
+#endif

+ 510 - 0
UB530SDK/UB530SDK/stdafx.cpp

@@ -0,0 +1,510 @@
+// stdafx.cpp : 只包括标准包含文件的源文件
+// UB530SDK.pch 将作为预编译头
+// stdafx.obj 将包含预编译类型信息
+
+#include "stdafx.h"
+#include <time.h> //或者 #include <ctime>
+#include <locale.h>
+// TODO: 在 STDAFX.H 中
+// 引用任何所需的附加头文件,而不是在此文件中引用
+// 全局变量;
+// 进程ID;
+DWORD g_dwAppId = 0;
+TCHAR g_szAppDir[MAX_PATH] = {0};
+
+// crc32校验;
+static int crc_table_empty = 1;
+static void make_crc_table (void);
+static const unsigned long crc_table[256] = {
+	0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
+	0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
+	0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
+	0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
+	0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
+	0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
+	0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
+	0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
+	0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
+	0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
+	0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
+	0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
+	0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
+	0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
+	0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
+	0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
+	0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
+	0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
+	0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
+	0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
+	0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
+	0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
+	0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
+	0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
+	0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
+	0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
+	0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
+	0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
+	0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
+	0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
+	0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
+	0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
+	0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
+	0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
+	0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
+	0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
+	0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
+	0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
+	0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
+	0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
+	0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
+	0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
+	0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
+	0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
+	0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
+	0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
+	0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
+	0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
+	0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
+	0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
+	0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
+	0x2d02ef8dL
+};
+
+const unsigned long * get_crc_table()
+{
+	return (const unsigned long *)crc_table;
+}
+
+/* ========================================================================= */
+#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
+#define DO2(buf)  DO1(buf); DO1(buf);
+#define DO4(buf)  DO2(buf); DO2(buf);
+#define DO8(buf)  DO4(buf); DO4(buf);
+
+/************************************************************************/
+/*  函数:[7/4/2018 Wang];
+/*  描述:crc32校验;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned int len)
+{
+	if (buf == 0) return 0L;
+	crc = crc ^ 0xffffffffUL;
+	while (len >= 8)
+	{
+		DO8(buf);
+		len -= 8;
+	}
+	if (len) do {
+		DO1(buf);
+	} while (--len);
+	return crc ^ 0xffffffffUL;
+}
+
+/************************************************************************/
+/*  函数:[7/3/2018 Wang];
+/*  描述:提权函数;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+BOOL GetDebugPriv()
+{
+	// 返回的访问令牌指针;
+	HANDLE	hToken;
+	// 接收所返回的制定特权名称的信息;
+	LUID	sedebugnameValue;
+	// 新特权信息的指针(结构体);
+	TOKEN_PRIVILEGES tkp;
+	DWORD	dwCurProcId = GetCurrentProcessId();
+	// 要修改访问权限的进程句柄;
+	HANDLE	hCurProc;
+	hCurProc = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwCurProcId);
+
+	if (!::OpenProcessToken(hCurProc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
+	{
+		ShowSystemErrorInfo(_T("OpenProcessToken失败"),GetLastError());
+		return FALSE;
+	}
+
+	if (!::LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &sedebugnameValue))
+	{
+		ShowSystemErrorInfo(_T("LookupPrivilegeValue失败"), GetLastError());
+		CloseHandle(hToken);
+		return FALSE;
+	}
+
+	tkp.PrivilegeCount = 1;
+	tkp.Privileges[0].Luid = sedebugnameValue;
+	tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+
+	if (!::AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof tkp, NULL, NULL))
+	{
+		ShowSystemErrorInfo(_T("升级包AdjustTokenPrivileges失败."), GetLastError());
+		CloseHandle(hToken);
+		return FALSE;
+	}
+
+	CloseHandle(hCurProc);
+	CloseHandle(hToken);
+	return TRUE;
+}
+
+/************************************************************************/
+/*  函数:[7/3/2018 Wang];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:非线程安全;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+void ShowSystemErrorInfo( LPCTSTR lpszTitle,const DWORD &dwError)
+{
+	LPVOID lpMsgBuf;
+	static TCHAR szResult[MAX_PATH] = {0};
+	memset(szResult, 0, sizeof(TCHAR)*MAX_PATH);
+	BOOL fOk = FormatMessage(
+		FORMAT_MESSAGE_ALLOCATE_BUFFER |
+		FORMAT_MESSAGE_FROM_SYSTEM |
+		FORMAT_MESSAGE_IGNORE_INSERTS,
+		NULL,
+		dwError,
+		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+		(LPTSTR)&lpMsgBuf,
+		0, NULL);
+
+	if (!fOk)
+	{
+		// Is it a network-related error?
+		HMODULE hDll = LoadLibraryEx(TEXT("netmsg.dll"), NULL, DONT_RESOLVE_DLL_REFERENCES);
+
+		if (hDll != NULL)
+		{
+			FormatMessage(
+				FORMAT_MESSAGE_FROM_HMODULE |
+				FORMAT_MESSAGE_FROM_SYSTEM |
+				FORMAT_MESSAGE_IGNORE_INSERTS,
+				hDll,
+				dwError,
+				MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
+				(LPTSTR)&lpMsgBuf,
+				0,
+				NULL);
+
+			FreeLibrary(hDll);
+		}
+	}
+
+	if (lpMsgBuf != NULL)
+	{
+		_stprintf_s(szResult, _T("%s:%ld,%s"), lpszTitle == NULL ? _T("错误") : lpszTitle, dwError, (PCTSTR)LocalLock(lpMsgBuf));
+		WriteTextLog(szResult);
+		LocalFree(lpMsgBuf);
+	}
+	else
+	{
+		_stprintf_s(szResult, _T("%s:未知错误!"),lpszTitle == NULL ? _T("错误") : lpszTitle);
+		WriteTextLog(szResult);
+	}
+}
+
+/************************************************************************/
+/*  函数:[7/3/2018 Wang];
+/*  描述:进程是否在运行;
+/*  参数:;
+/*  	[IN] lpszAppDir:执行程序绝对路径;
+/*  返回:若进程存在,返回非0值;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+DWORD IsAppRunning(LPCTSTR lpszAppDir)
+{
+	if (!lpszAppDir || !PathFileExists(lpszAppDir))
+		return 0;
+
+	TString strAppDir = lpszAppDir;
+	int nIndex =strAppDir.find('/');
+	while (nIndex != TString::npos) 
+	{
+		strAppDir.replace(nIndex, 1, _T("\\"));
+		nIndex = strAppDir.find('/');
+	} 
+	nIndex = strAppDir.find_last_of(_T('\\'));
+	if (nIndex != TString::npos )
+		strAppDir = strAppDir.substr(nIndex+1);
+
+	DWORD dwProcessID = 0;
+	PROCESSENTRY32 pe32 = { 0 };
+
+	HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+	if (hProcessSnap == NULL)
+	{
+		ShowSystemErrorInfo(_T("获取进程快照失败"),GetLastError());
+		return 0;
+	}
+	pe32.dwSize = sizeof(PROCESSENTRY32);
+
+	if (Process32First(hProcessSnap, &pe32))
+	{
+		do
+		{
+			// szExeFile只是文件名,不知道是否只有win10才这样;
+			if (_tcsicmp(strAppDir.c_str(), pe32.szExeFile) == 0)
+			{
+				dwProcessID = pe32.th32ProcessID;
+				break;
+			}
+		} while (Process32Next(hProcessSnap, &pe32));
+	}
+	CloseHandle(hProcessSnap);
+
+	return dwProcessID;
+}
+
+/************************************************************************/
+/*  函数:[7/3/2018 Wang];
+/*  描述:关闭进程;
+/*  参数:;
+/*  	[IN] dwAppId:进程ID;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+bool CloseApp(DWORD dwAppId)
+{
+	if ( dwAppId == 0 )
+		return false;
+
+	HANDLE hProcess = ::OpenProcess(PROCESS_ALL_ACCESS, TRUE, dwAppId);
+	if (hProcess == NULL)
+	{
+		ShowSystemErrorInfo(_T("打开进程失败"),GetLastError());
+		return false;
+	}
+
+	DWORD dwError;
+	if (!TerminateProcess(hProcess, 0))
+	{
+		dwError = GetLastError();
+		CloseHandle(hProcess);
+		hProcess = NULL;
+		return false;
+	}
+
+	// 等待进程结束响应;
+	if (WAIT_OBJECT_0 != WaitForSingleObject(hProcess, INFINITE))
+	{
+		CloseHandle(hProcess);
+		return false;
+	}
+
+	CloseHandle(hProcess);
+	hProcess = NULL;
+
+	return true;
+}
+
+
+/************************************************************************/
+/*  函数:WriteTextLog[7/28/2016 IT];
+/*  描述:写文本日志;
+/*  参数:;
+/*  	[IN] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+void WriteTextLog(const TCHAR *format, ...)
+{
+	//static ThreadSection _critSection;
+	//AutoThreadSection aSection(&_critSection);
+	// 解析出日志路径;
+	TCHAR szlogpath[MAX_PATH] = {0};
+	static TCHAR szModulePath[MAX_PATH] = {0};
+	static TCHAR szFna[_MAX_DIR] = { 0 };
+	if ( szModulePath[0] == _T('\0') )
+	{
+		TCHAR szDrive[_MAX_DRIVE] = { 0 };
+		TCHAR szDir[_MAX_DIR] = { 0 };
+		TCHAR szExt[_MAX_DIR] = { 0 };
+		::GetModuleFileName(NULL, szModulePath, sizeof(szModulePath) / sizeof(TCHAR));
+		_tsplitpath_s(szModulePath, szDrive, szDir, szFna, szExt);
+		_tcscpy_s(szModulePath, szDrive);
+		_tcscat_s(szModulePath, szDir);
+	}
+
+	// 获取今年年份;
+	__time64_t gmt = time(NULL);// 获取当前日历时间(1900-01-01开始的Unix时间戳);
+	struct tm gmtm = {0};
+	//gmtime_s(&gmtm, &gmt); // 时间戳转成UTC时间(也叫GMT时间);
+	localtime_s(&gmtm, &gmt); // 时间戳转成本地时间;
+	_stprintf_s(szlogpath, _T("%s%s%04d-%02d-%02d.txt"), szModulePath, szFna, gmtm.tm_year + 1900, gmtm.tm_mon+1, gmtm.tm_mday);
+
+	// 打开或创建文件;
+#if 0 // MFC
+	CStdioFile fp;
+	if (PathFileExists(szlogpath))
+	{
+		if (fp.Open(szlogpath, CFile::modeWrite) == FALSE)
+		{
+			return;
+		}
+		fp.SeekToEnd();
+	}
+	else
+	{
+		fp.Open(szlogpath, CFile::modeCreate | CFile::modeWrite);
+	}
+
+	// 格式化前设置语言区域;
+	TCHAR* old_locale = _tcsdup(_tsetlocale(LC_CTYPE, NULL));
+	_tsetlocale(LC_CTYPE, _T("chs"));//设定中文;
+
+	// 格式化日志内容;
+	va_list		args = NULL;
+	int			len = 0;
+	TCHAR		*buffer = NULL;
+	va_start( args, format );
+	// _vscprintf doesn't count. terminating '\0'
+	len = _vsctprintf( format, args )  + 1;
+	buffer = (TCHAR*)malloc( len * sizeof(TCHAR) );
+	_vstprintf_s( buffer, len, format, args ); // C4996
+	// Note: vsprintf is deprecated; consider using vsprintf_s instead
+
+	// 将日志内容输入到文件中;
+	fp.WriteString( CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S ")) );
+	fp.WriteString(buffer);
+	fp.WriteString(_T("\n"));
+
+	// 关闭文件,释放资源并设置回原语言区域;
+	free( buffer );
+	_tsetlocale(LC_CTYPE, old_locale);
+	free(old_locale);//还原区域设定;
+	fp.Close();
+#else // 不依赖MFC;
+	FILE *fp = NULL;
+	fp = _tfopen(szlogpath, _T("a+"));
+	if ( fp == NULL )
+		return;
+
+	fseek(fp, 0, SEEK_END);
+
+	// 格式化前设置语言区域;
+	TCHAR* old_locale = _tcsdup(_tsetlocale(LC_CTYPE, NULL));
+	_tsetlocale(LC_CTYPE, _T("chs"));//设定中文;
+
+	// 格式化日志内容;
+	va_list		args = NULL;
+	int			len = 0;
+	TCHAR		*buffer = NULL;
+	va_start( args, format );
+	// _vscprintf doesn't count. terminating '\0'
+	len = _vsctprintf( format, args )  + 1;
+	buffer = (TCHAR*)malloc( len * sizeof(TCHAR) );
+	_vstprintf_s( buffer, len, format, args ); // C4996
+	// Note: vsprintf is deprecated; consider using vsprintf_s instead
+
+	// 将日志内容输入到文件中;
+	TCHAR szTime[36] = {0};
+	_stprintf_s(szTime, _T("%04d-%02d-%02d %02d:%02d:%02d  "), gmtm.tm_year + 1900, gmtm.tm_mon+1, gmtm.tm_mday, gmtm.tm_hour, gmtm.tm_min, gmtm.tm_sec);
+	fwrite(szTime, _tcslen(szTime)*sizeof(TCHAR), 1, fp);
+	fwrite(buffer, _tcslen(buffer)*sizeof(TCHAR), 1, fp);
+	fwrite(_T("\n"), sizeof(TCHAR), 1, fp);
+
+	// 关闭文件,释放资源并设置回原语言区域;
+	free( buffer );
+	_tsetlocale(LC_CTYPE, old_locale);
+	free(old_locale);//还原区域设定;
+	
+	fclose(fp);
+
+#endif
+}
+
+
+/************************************************************************/
+/*  函数:[8/13/2018 jianfeng1.wang];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+void findfile(IN CONST TString& folder, IN vector<TString> &files)
+{
+	TString path = folder;
+	if (path.size() > 0 && '\\' != path[path.size() - 1])
+		path.append(_T("\\"));
+
+	TString file = _T("*");
+	TString s = path + file;
+
+	WIN32_FIND_DATA fileinfo = { 0 };
+	HANDLE handle = FindFirstFile(s.c_str(), &fileinfo);
+
+	if (NULL != handle && INVALID_HANDLE_VALUE != handle)
+	{
+		do
+		{
+			// '.'和 '..'的系统文件去除;
+			if (_T('.') != fileinfo.cFileName[0])
+			{
+				if ((FILE_ATTRIBUTE_DIRECTORY & fileinfo.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY)	// 目录;
+				{
+					findfile(path + fileinfo.cFileName, files);
+				}
+				else
+				{
+					files.push_back(path + fileinfo.cFileName);
+				}
+			}
+
+		} while (FindNextFile(handle, &fileinfo));
+
+		FindClose(handle);
+	}
+}

+ 48 - 0
UB530SDK/UB530SDK/stdafx.h

@@ -0,0 +1,48 @@
+// stdafx.h : 标准系统包含文件的包含文件,
+// 或是经常使用但不常更改的
+// 特定于项目的包含文件
+//
+
+#pragma once
+
+#include "targetver.h"
+
+#define WIN32_LEAN_AND_MEAN             // 从 Windows 头中排除极少使用的资料
+// Windows 头文件:
+#include <windows.h>
+
+
+#include <shlwapi.h>
+#pragma comment(lib,"Shlwapi.lib")
+#include <tlhelp32.h>
+#include <shellapi.h>
+#include <tchar.h>
+#include <stdio.h>
+#include <string>
+using namespace std;
+//#include "CD750Proto.h"
+
+#ifndef _UNICODE 
+typedef string TString;
+#else
+typedef wstring TString;
+#endif
+
+#include <vector>
+using namespace std;
+
+// 全局变量;
+extern DWORD g_dwAppId;
+extern TCHAR g_szAppDir[MAX_PATH];
+
+// 全局函数;
+extern BOOL GetDebugPriv();
+extern void ShowSystemErrorInfo( LPCTSTR lpszTitle,const DWORD &dwError);
+extern DWORD IsAppRunning(LPCTSTR lpszAppDir);
+extern bool CloseApp(DWORD dwAppId);
+extern void WriteTextLog(const TCHAR *format, ...);
+extern unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned int len);
+extern void findfile(IN CONST TString& folder, IN vector<TString> &files);
+
+
+// TODO: 在此处引用程序需要的其他头文件

+ 24 - 0
UB530SDK/UB530SDK/targetver.h

@@ -0,0 +1,24 @@
+#pragma once
+
+// 以下宏定义要求的最低平台。要求的最低平台
+// 是具有运行应用程序所需功能的 Windows、Internet Explorer 等产品的
+// 最早版本。通过在指定版本及更低版本的平台上启用所有可用的功能,宏可以
+// 正常工作。
+
+// 如果必须要针对低于以下指定版本的平台,请修改下列定义。
+// 有关不同平台对应值的最新信息,请参考 MSDN。
+#ifndef WINVER                          // 指定要求的最低平台是 Windows Vista。
+#define WINVER 0x0600           // 将此值更改为相应的值,以适用于 Windows 的其他版本。
+#endif
+
+#ifndef _WIN32_WINNT            // 指定要求的最低平台是 Windows Vista。
+#define _WIN32_WINNT 0x0600     // 将此值更改为相应的值,以适用于 Windows 的其他版本。
+#endif
+
+#ifndef _WIN32_WINDOWS          // 指定要求的最低平台是 Windows 98。
+#define _WIN32_WINDOWS 0x0410 // 将此值更改为适当的值,以适用于 Windows Me 或更高版本。
+#endif
+
+#ifndef _WIN32_IE                       // 指定要求的最低平台是 Internet Explorer 7.0。
+#define _WIN32_IE 0x0700        // 将此值更改为相应的值,以适用于 IE 的其他版本。
+#endif

+ 40 - 0
UB530SDK/test/ReadMe.txt

@@ -0,0 +1,40 @@
+========================================================================
+    控制台应用程序:test 项目概述
+========================================================================
+
+应用程序向导已为您创建了此 test 应用程序。
+
+本文件概要介绍组成 test 应用程序的
+的每个文件的内容。
+
+
+test.vcproj
+    这是使用应用程序向导生成的 VC++ 项目的主项目文件,
+    其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
+
+test.cpp
+    这是主应用程序源文件。
+
+/////////////////////////////////////////////////////////////////////////////
+应用程序向导创建了下列资源:
+
+test.rc
+这是程序使用的所有 Microsoft Windows 资源的列表。它包括 RES 子目录中存储的图标、位图和光标。
+此文件可以直接在 Microsoft Visual C++ 中进行编辑。
+
+Resource.h
+    这是标准头文件,可用于定义新的资源 ID。
+    Microsoft Visual C++ 将读取并更新此文件。
+
+/////////////////////////////////////////////////////////////////////////////
+其他标准文件:
+
+StdAfx.h, StdAfx.cpp
+    这些文件用于生成名为 test.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
+
+/////////////////////////////////////////////////////////////////////////////
+其他注释:
+
+应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
+
+/////////////////////////////////////////////////////////////////////////////

+ 17 - 0
UB530SDK/test/Resource.h

@@ -0,0 +1,17 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by test.rc
+//
+
+#define IDS_APP_TITLE			103
+
+// жÔÏóµÄÏÂÒ»×éĬÈÏÖµ
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE	101
+#define _APS_NEXT_COMMAND_VALUE		40001
+#define _APS_NEXT_CONTROL_VALUE		1000
+#define _APS_NEXT_SYMED_VALUE		101
+#endif
+#endif

+ 196 - 0
UB530SDK/test/stdafx.cpp

@@ -0,0 +1,196 @@
+// stdafx.cpp : 只包括标准包含文件的源文件
+// test.pch 将作为预编译头
+// stdafx.obj 将包含预编译类型信息
+
+#include "stdafx.h"
+
+#include <time.h> //或者 #include <ctime>
+#include <locale.h>
+
+// TODO: 在 STDAFX.H 中
+// 引用任何所需的附加头文件,而不是在此文件中引用
+
+/************************************************************************/
+/*  函数:[7/3/2018 Wang];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:非线程安全;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+void ShowSystemErrorInfo( LPCTSTR lpszTitle,const DWORD &dwError)
+{
+	LPVOID lpMsgBuf;
+	static TCHAR szResult[MAX_PATH] = {0};
+	memset(szResult, 0, sizeof(TCHAR)*MAX_PATH);
+	BOOL fOk = FormatMessage(
+		FORMAT_MESSAGE_ALLOCATE_BUFFER |
+		FORMAT_MESSAGE_FROM_SYSTEM |
+		FORMAT_MESSAGE_IGNORE_INSERTS,
+		NULL,
+		dwError,
+		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+		(LPTSTR)&lpMsgBuf,
+		0, NULL);
+
+	if (!fOk)
+	{
+		// Is it a network-related error?
+		HMODULE hDll = LoadLibraryEx(TEXT("netmsg.dll"), NULL, DONT_RESOLVE_DLL_REFERENCES);
+
+		if (hDll != NULL)
+		{
+			FormatMessage(
+				FORMAT_MESSAGE_FROM_HMODULE |
+				FORMAT_MESSAGE_FROM_SYSTEM |
+				FORMAT_MESSAGE_IGNORE_INSERTS,
+				hDll,
+				dwError,
+				MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
+				(LPTSTR)&lpMsgBuf,
+				0,
+				NULL);
+
+			FreeLibrary(hDll);
+		}
+	}
+
+	if (lpMsgBuf != NULL)
+	{
+		_stprintf_s(szResult, _T("%s:%ld,%s"), lpszTitle == NULL ? _T("错误") : lpszTitle, dwError, (PCTSTR)LocalLock(lpMsgBuf));
+		WriteTextLog(szResult);
+		LocalFree(lpMsgBuf);
+	}
+	else
+	{
+		_stprintf_s(szResult, _T("%s:未知错误!"),lpszTitle == NULL ? _T("错误") : lpszTitle);
+		WriteTextLog(szResult);
+	}
+}
+
+/************************************************************************/
+/*  函数:WriteTextLog[7/28/2016 IT];
+/*  描述:写文本日志;
+/*  参数:;
+/*  	[IN] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+void WriteTextLog(const TCHAR *format, ...)
+{
+	//static ThreadSection _critSection;
+	//AutoThreadSection aSection(&_critSection);
+	// 解析出日志路径;
+	TCHAR szlogpath[MAX_PATH] = {0};
+	static TCHAR szModulePath[MAX_PATH] = {0};
+	static TCHAR szFna[_MAX_DIR] = { 0 };
+	if ( szModulePath[0] == _T('\0') )
+	{
+		TCHAR szDrive[_MAX_DRIVE] = { 0 };
+		TCHAR szDir[_MAX_DIR] = { 0 };
+		TCHAR szExt[_MAX_DIR] = { 0 };
+		::GetModuleFileName(NULL, szModulePath, sizeof(szModulePath) / sizeof(TCHAR));
+		_tsplitpath_s(szModulePath, szDrive, szDir, szFna, szExt);
+		_tcscpy_s(szModulePath, szDrive);
+		_tcscat_s(szModulePath, szDir);
+	}
+
+	// 获取今年年份;
+	__time64_t gmt = time(NULL);// 获取当前日历时间(1900-01-01开始的Unix时间戳);
+	struct tm gmtm = {0};
+	//gmtime_s(&gmtm, &gmt); // 时间戳转成UTC时间(也叫GMT时间);
+	localtime_s(&gmtm, &gmt); // 时间戳转成本地时间;
+	_stprintf_s(szlogpath, _T("%s%s%04d-%02d-%02d.txt"), szModulePath, szFna, gmtm.tm_year + 1900, gmtm.tm_mon+1, gmtm.tm_mday);
+
+	// 打开或创建文件;
+#if 0 // MFC
+	CStdioFile fp;
+	if (PathFileExists(szlogpath))
+	{
+		if (fp.Open(szlogpath, CFile::modeWrite) == FALSE)
+		{
+			return;
+		}
+		fp.SeekToEnd();
+	}
+	else
+	{
+		fp.Open(szlogpath, CFile::modeCreate | CFile::modeWrite);
+	}
+
+	// 格式化前设置语言区域;
+	TCHAR* old_locale = _tcsdup(_tsetlocale(LC_CTYPE, NULL));
+	_tsetlocale(LC_CTYPE, _T("chs"));//设定中文;
+
+	// 格式化日志内容;
+	va_list		args = NULL;
+	int			len = 0;
+	TCHAR		*buffer = NULL;
+	va_start( args, format );
+	// _vscprintf doesn't count. terminating '\0'
+	len = _vsctprintf( format, args )  + 1;
+	buffer = (TCHAR*)malloc( len * sizeof(TCHAR) );
+	_vstprintf_s( buffer, len, format, args ); // C4996
+	// Note: vsprintf is deprecated; consider using vsprintf_s instead
+
+	// 将日志内容输入到文件中;
+	fp.WriteString( CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S ")) );
+	fp.WriteString(buffer);
+	fp.WriteString(_T("\n"));
+
+	// 关闭文件,释放资源并设置回原语言区域;
+	free( buffer );
+	_tsetlocale(LC_CTYPE, old_locale);
+	free(old_locale);//还原区域设定;
+	fp.Close();
+#else // 不依赖MFC;
+	FILE *fp = NULL;
+	fp = _tfopen(szlogpath, _T("a+"));
+	if ( fp == NULL )
+		return;
+
+	fseek(fp, 0, SEEK_END);
+
+	// 格式化前设置语言区域;
+	TCHAR* old_locale = _tcsdup(_tsetlocale(LC_CTYPE, NULL));
+	_tsetlocale(LC_CTYPE, _T("chs"));//设定中文;
+
+	// 格式化日志内容;
+	va_list		args = NULL;
+	int			len = 0;
+	TCHAR		*buffer = NULL;
+	va_start( args, format );
+	// _vscprintf doesn't count. terminating '\0'
+	len = _vsctprintf( format, args )  + 1;
+	buffer = (TCHAR*)malloc( len * sizeof(TCHAR) );
+	_vstprintf_s( buffer, len, format, args ); // C4996
+	// Note: vsprintf is deprecated; consider using vsprintf_s instead
+
+	// 将日志内容输入到文件中;
+	TCHAR szTime[36] = {0};
+	_stprintf_s(szTime, _T("%04d-%02d-%02d %02d:%02d:%02d  "), gmtm.tm_year + 1900, gmtm.tm_mon+1, gmtm.tm_mday, gmtm.tm_hour, gmtm.tm_min, gmtm.tm_sec);
+	fwrite(szTime, _tcslen(szTime)*sizeof(TCHAR), 1, fp);
+	fwrite(buffer, _tcslen(buffer)*sizeof(TCHAR), 1, fp);
+	fwrite(_T("\n"), sizeof(TCHAR), 1, fp);
+
+	// 关闭文件,释放资源并设置回原语言区域;
+	free( buffer );
+	_tsetlocale(LC_CTYPE, old_locale);
+	free(old_locale);//还原区域设定;
+
+	fclose(fp);
+
+#endif
+}

+ 44 - 0
UB530SDK/test/stdafx.h

@@ -0,0 +1,44 @@
+// stdafx.h : 标准系统包含文件的包含文件,
+// 或是经常使用但不常更改的
+// 特定于项目的包含文件
+//
+
+#pragma once
+
+#include "targetver.h"
+
+#include <stdio.h>
+#include <tchar.h>
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // 某些 CString 构造函数将是显式的
+
+#ifndef VC_EXTRALEAN
+#define VC_EXTRALEAN            // 从 Windows 头中排除极少使用的资料
+#endif
+
+#include <afx.h>
+#include <afxwin.h>         // MFC 核心组件和标准组件
+#include <afxext.h>         // MFC 扩展
+#ifndef _AFX_NO_OLE_SUPPORT
+#include <afxdtctl.h>           // MFC 对 Internet Explorer 4 公共控件的支持
+#endif
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h>                     // MFC 对 Windows 公共控件的支持
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+#include <iostream>
+
+
+#include <string>
+using namespace std;
+#include "MemoryServer.h"
+
+#ifndef _UNICODE 
+typedef string TString;
+#else
+typedef wstring TString;
+#endif
+
+
+extern void ShowSystemErrorInfo( LPCTSTR lpszTitle,const DWORD &dwError);
+extern void WriteTextLog(const TCHAR *format, ...);
+// TODO: 在此处引用程序需要的其他头文件

+ 24 - 0
UB530SDK/test/targetver.h

@@ -0,0 +1,24 @@
+#pragma once
+
+// 以下宏定义要求的最低平台。要求的最低平台
+// 是具有运行应用程序所需功能的 Windows、Internet Explorer 等产品的
+// 最早版本。通过在指定版本及更低版本的平台上启用所有可用的功能,宏可以
+// 正常工作。
+
+// 如果必须要针对低于以下指定版本的平台,请修改下列定义。
+// 有关不同平台对应值的最新信息,请参考 MSDN。
+#ifndef WINVER                          // 指定要求的最低平台是 Windows Vista。
+#define WINVER 0x0600           // 将此值更改为相应的值,以适用于 Windows 的其他版本。
+#endif
+
+#ifndef _WIN32_WINNT            // 指定要求的最低平台是 Windows Vista。
+#define _WIN32_WINNT 0x0600     // 将此值更改为相应的值,以适用于 Windows 的其他版本。
+#endif
+
+#ifndef _WIN32_WINDOWS          // 指定要求的最低平台是 Windows 98。
+#define _WIN32_WINDOWS 0x0410 // 将此值更改为适当的值,以适用于 Windows Me 或更高版本。
+#endif
+
+#ifndef _WIN32_IE                       // 指定要求的最低平台是 Internet Explorer 7.0。
+#define _WIN32_IE 0x0700        // 将此值更改为相应的值,以适用于 IE 的其他版本。
+#endif

+ 79 - 0
UB530SDK/test/test.cpp

@@ -0,0 +1,79 @@
+// test.cpp : 定义控制台应用程序的入口点。
+//
+
+#include "stdafx.h"
+#include "test.h"
+#include "MemoryServer.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+
+// 唯一的应用程序对象
+
+CWinApp theApp;
+
+using namespace std;
+
+int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
+{
+	int nRetCode = 0;
+
+	// 初始化 MFC 并在失败时显示错误
+	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
+	{
+		// TODO: 更改错误代码以符合您的需要
+		_tprintf(_T("错误: MFC 初始化失败\n"));
+		nRetCode = 1;
+	}
+	else
+	{
+		// TODO: 在此处为应用程序的行为编写代码。
+		CMemoryServer ms;
+		if ( ms.InitMemery() == FALSE )
+		{
+			printf("初始化共享内存失败\n");
+		}
+
+		if (ms.StartApp("VideoCapture.exe"))
+		{
+			printf("打开程序成功\n");
+			Sleep(2000);
+			ms.ConnectDevice();
+			//printf("连接设备\n");
+
+
+			//Sleep(12000);
+			//printf("CaptureSingleImage\n");
+			// 持续方式:以张数为单位;
+			TCHAR szName[MAX_PATH] = { 0 };
+			for (int i = 0; i < 10000; i++)
+			{
+				_stprintf(szName, _T("D:\\test\\%02d.jpg"), i);
+				ms.CaptureSingleImage(szName, 2, TRUE);
+			}
+			//printf("%ld\n", GetTickCount() - dwTickCount);
+			//Sleep(120);
+			//printf("CaptureImageByCount\n");
+			// 持续方式:以秒为单位;
+			//cd750.CaptureImageByCount(1/*每秒多少张*/, _T(".\\ByCount\\"));
+			//Sleep(12000);
+			//printf("CaptureImageByTime\n");
+			// 持续方式:以秒为单位;
+			//ms.CaptureImageByTime(  12000/*持续时间,秒*/, 20/*每秒多少张*/, _T("F:\\bin\\VideoCapture\\aaaa\\"), _T("dfdf"));
+			//printf("CaptureAudio\n");
+			Sleep(1000);
+
+			//cd750.SynCaptureAudio(_T(".\\Audio\\"));
+
+
+			ms.DisconnectDevice();
+
+			printf("结束\n");
+			getchar();
+		}
+	}
+
+	return nRetCode;
+}

+ 3 - 0
UB530SDK/test/test.h

@@ -0,0 +1,3 @@
+#pragma once
+
+#include "resource.h"

+ 69 - 0
UB530SDK/test/test.rc

@@ -0,0 +1,69 @@
+//Microsoft Visual C++ 生成的资源脚本。
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// 从 TEXTINCLUDE 2 资源生成。
+//
+#include "afxres.h"
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
+LANGUAGE 4, 2
+#pragma code_page(936)
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// 字符串表
+//
+
+STRINGTABLE
+BEGIN
+   IDS_APP_TITLE       "test"
+END
+
+#endif
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// 从 TEXTINCLUDE 3 资源生成。
+//
+#ifndef _AFXDLL
+#include "l.CHS\\afxres.rc"
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // 不是 APSTUDIO_INVOKED

+ 261 - 0
UB530SDK/test/test.vcproj

@@ -0,0 +1,261 @@
+<?xml version="1.0" encoding="gb2312"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="test"
+	ProjectGUID="{602679D5-A295-4539-9D15-B8E07C2BF203}"
+	RootNamespace="test"
+	Keyword="Win32Proj"
+	TargetFrameworkVersion="196613"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="..\..\..\..\bin\$(SolutionName)"
+			IntermediateDirectory="$(OutDir)\$(ProjectName)\$(ConfigurationName)"
+			ConfigurationType="1"
+			UseOfMFC="2"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\UB530SDK"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;__TESET__"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="2"
+				WarningLevel="3"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="2"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="..\..\..\..\bin\$(SolutionName)"
+			IntermediateDirectory="$(OutDir)\$(ProjectName)\$(ConfigurationName)"
+			ConfigurationType="1"
+			UseOfMFC="1"
+			CharacterSet="2"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				EnableIntrinsicFunctions="true"
+				AdditionalIncludeDirectories="..\UB530SDK"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;__TESET__"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				UsePrecompiledHeader="2"
+				WarningLevel="3"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="1"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Ô´Îļþ"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\UB530SDK\MemoryComm.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\UB530SDK\MemoryServer.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\stdafx.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath=".\test.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Í·Îļþ"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\UB530SDK\MemoryComm.h"
+				>
+			</File>
+			<File
+				RelativePath="..\UB530SDK\MemoryDef.h"
+				>
+			</File>
+			<File
+				RelativePath="..\UB530SDK\MemoryServer.h"
+				>
+			</File>
+			<File
+				RelativePath=".\Resource.h"
+				>
+			</File>
+			<File
+				RelativePath=".\stdafx.h"
+				>
+			</File>
+			<File
+				RelativePath=".\targetver.h"
+				>
+			</File>
+			<File
+				RelativePath=".\test.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="×ÊÔ´Îļþ"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+			<File
+				RelativePath=".\test.rc"
+				>
+			</File>
+		</Filter>
+		<File
+			RelativePath=".\ReadMe.txt"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>