allcam.cpp
来自「用Embedded Visual C++ Win32 API开发的运行于Wind」· C++ 代码 · 共 96 行
CPP
96 行
// AllCam.cpp: implementation of the CAllCam class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "AllCam.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CAllCam::CAllCam()
{
memset(this->Server , 0, _tcslen(this->Server )* sizeof(TCHAR));
this->num =0;
this->pCam =NULL;
this->curPos =0;
}
CAllCam::~CAllCam()
{
if(this->pCam !=NULL) { free(this->pCam) ; this->pCam =NULL; }
}
void CAllCam::Init()
{
memset(this->Server , 0, _tcslen(this->Server )* sizeof(TCHAR));
this->num =0;
if(this->pCam !=NULL) { free(this->pCam) ; this->pCam =NULL; }
this->curPos =0;
}
BOOL CAllCam::RetrieveFromRegistry()
{
HKEY hKey = NULL;
DWORD dwWord =0;
if(::RegOpenKeyEx (HKEY_CURRENT_USER, REGPATH, 0, 0, &hKey) != ERROR_SUCCESS)
{
this->InitializeRegistry ();
if(::RegCreateKeyEx(HKEY_CURRENT_USER, REGPATH, 0, NULL, 0, 0, NULL, &hKey, &dwWord) != ERROR_SUCCESS)
return FALSE;
}
this->Init ();
DWORD dwType;
dwWord = 255*sizeof(TCHAR);
dwType = REG_MULTI_SZ;
::RegQueryValueEx (hKey, _T("Server"), 0, &dwType, (LPBYTE)this->Server , &dwWord);
DWORD dwSubKey, dwValues;
if(::RegQueryInfoKey (hKey, NULL, NULL, NULL, &dwSubKey, NULL, NULL, &dwValues, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
{
::RegCloseKey (hKey);
return FALSE;
}
this->num = dwSubKey;
if(this->pCam !=NULL) { free(this->pCam) ; this->pCam =NULL; }
do { this->pCam = (CCamDesc *)malloc(this->num *sizeof(CCamDesc)); }while(this->pCam ==NULL);
int index =0;
TCHAR subKey[255];
DWORD keySize= 255;
CCamDesc *p;
while(::RegEnumKeyEx (hKey, index, subKey, &keySize, NULL, NULL, NULL, NULL)!=ERROR_NO_MORE_ITEMS)
{
p= this->pCam + index;
p->LoadMe (subKey);
index++;
keySize= 255;
}
::RegCloseKey (hKey);
return TRUE;
}
BOOL CAllCam::InitializeRegistry()
{
CCamDesc *theCam;
for(int i=0; i<this->num ; i++)
{
theCam = this->pCam ;
theCam +=i;
theCam->SaveMe ();
}
return TRUE;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?