📄 camdesc.cpp
字号:
// CamDesc.cpp: implementation of the CCamDesc class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "CamDesc.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CCamDesc::CCamDesc()
{
memset(this->Name , 0, 255*sizeof(TCHAR));
memset(this->Path , 0, 255*sizeof(TCHAR));
memset(this->Type , 0, 255*sizeof(TCHAR));
memset(this->Username , 0, 255*sizeof(TCHAR));
memset(this->Password , 0, 255*sizeof(TCHAR));
this->Status =0;
this->IO =0;
this->PTZ =0;
}
CCamDesc::CCamDesc(CCamDesc& theCam)
{
memcpy(this->Name, theCam.Name , 255*sizeof(TCHAR));
memcpy(this->Path , theCam.Path , 255*sizeof(TCHAR));
memcpy(this->Type , theCam.Type , 255*sizeof(TCHAR));
memcpy(this->Username , theCam.Username , 255*sizeof(TCHAR));
memcpy(this->Password , theCam.Password , 255*sizeof(TCHAR));
this->Status = theCam.Status ;
this->IO = theCam.IO ;
this->PTZ = theCam.PTZ ;
}
CCamDesc::~CCamDesc()
{
}
BOOL CCamDesc::SaveMe()
{
HKEY hKey = NULL;
DWORD dwWord =0;
TCHAR thePath[1024];
_tcscpy(thePath, REGPATH);
_tcscat(thePath, _T("\\") );
_tcscat(thePath, this->Name );
if(::RegCreateKeyEx(HKEY_CURRENT_USER, thePath, 0, NULL, 0, 0, NULL, &hKey, &dwWord) != ERROR_SUCCESS)
return FALSE;
::RegSetValueEx (hKey, _T("Path") , NULL, REG_MULTI_SZ, (LPBYTE)this->Path , _tcslen(this->Path )*sizeof(TCHAR) );
::RegSetValueEx (hKey, _T("Username") , NULL, REG_MULTI_SZ, (LPBYTE)this->Username , _tcslen(this->Username )*sizeof(TCHAR) );
::RegSetValueEx (hKey, _T("Password") , NULL, REG_MULTI_SZ, (LPBYTE)this->Password , _tcslen(this->Password )*sizeof(TCHAR) );
::RegSetValueEx (hKey, _T("Type") , NULL, REG_MULTI_SZ, (LPBYTE)this->Type , _tcslen(this->Type )*sizeof(TCHAR) );
::RegSetValueEx (hKey, _T("Status") , NULL, REG_DWORD, (LPBYTE)&(this->Status ), sizeof(DWORD) );
::RegSetValueEx (hKey, _T("IO") , NULL, REG_DWORD, (LPBYTE)&(this->IO ), sizeof(DWORD) );
::RegSetValueEx (hKey, _T("PTZ") , NULL, REG_DWORD, (LPBYTE)&(this->PTZ ), sizeof(DWORD) );
::RegCloseKey (hKey);
return TRUE;
}
BOOL CCamDesc::LoadMe(TCHAR *theName)
{
TCHAR thePath[1024];
_tcscpy(thePath, REGPATH);
_tcscat(thePath, _T("\\") );
_tcscat(thePath, theName );
HKEY hKey = NULL;
DWORD dwWord =0;
DWORD dwType;
if(::RegCreateKeyEx(HKEY_CURRENT_USER, thePath, 0, NULL, 0, 0, NULL, &hKey, &dwWord) != ERROR_SUCCESS)
return FALSE;
CCamDesc theCam;
dwWord = 255*sizeof(TCHAR);
dwType = REG_MULTI_SZ;
if(::RegQueryValueEx (hKey, _T("Path"), NULL, &dwType , (LPBYTE)theCam.Path , &dwWord) != ERROR_SUCCESS) { ::RegCloseKey (hKey); return FALSE; }
dwWord = 255*sizeof(TCHAR);
dwType = REG_MULTI_SZ;
if(::RegQueryValueEx (hKey, _T("Username"), NULL, &dwType , (LPBYTE)theCam.Username , &dwWord) != ERROR_SUCCESS) { ::RegCloseKey (hKey); return FALSE; }
dwWord = 255*sizeof(TCHAR);
dwType = REG_MULTI_SZ;
if(::RegQueryValueEx (hKey, _T("Password"), NULL, &dwType , (LPBYTE)theCam.Password , &dwWord) != ERROR_SUCCESS) { ::RegCloseKey (hKey); return FALSE; }
dwWord = 255*sizeof(TCHAR);
dwType = REG_MULTI_SZ;
if(::RegQueryValueEx (hKey, _T("Type"), 0, &dwType , (LPBYTE)theCam.Type , &dwWord) != ERROR_SUCCESS) { ::RegCloseKey (hKey); return FALSE; }
dwWord = sizeof(DWORD);
dwType = REG_DWORD;
if(::RegQueryValueEx (hKey, _T("Status"), 0, &dwType, (LPBYTE)&(theCam.Status) , &dwWord) != ERROR_SUCCESS) { ::RegCloseKey (hKey); return FALSE; }
dwWord = sizeof(DWORD);
dwType = REG_DWORD;
if(::RegQueryValueEx (hKey, _T("IO"), 0, &dwType, (LPBYTE)&(theCam.IO), &dwWord) != ERROR_SUCCESS) { ::RegCloseKey (hKey); return FALSE; }
dwWord = sizeof(DWORD);
dwType = REG_DWORD;
if(::RegQueryValueEx (hKey, _T("PTZ"), 0, &dwType, (LPBYTE)&(theCam.PTZ ) , &dwWord) != ERROR_SUCCESS) { ::RegCloseKey (hKey); return FALSE; }
_tcscpy(theCam.Name, theName);
*this = theCam;
::RegCloseKey (hKey);
return TRUE;
}
void CCamDesc::InitCameras()
{
CCamDesc theCam;
_tcscpy(theCam.Username , _T("root"));
_tcscpy(theCam.Password , _T("pass"));
_tcscpy(theCam. Name , _T("Demo3"));
_tcscpy(theCam. Path , _T("http://158.132.152.126:80/cgi-bin/fullsize.jpg?camera=4") );
_tcscpy(theCam. Type , _T("2400"));
theCam. Status = 0;
theCam. IO =0;
theCam. PTZ =0;
theCam.SaveMe ();
/////////////////////////////////////////
_tcscpy(theCam. Name , _T("Demo2"));
_tcscpy(theCam. Path , _T("http://158.132.152.128:80/cgi-bin/fullsize.jpg?camera=1&compression=3") );
_tcscpy(theCam. Type , _T("2400"));
theCam. Status = 0;
theCam. IO =0;
theCam. PTZ =1;
theCam.SaveMe ();
/////////////////////////////////////////
_tcscpy(theCam. Name , _T("Demo1"));
_tcscpy(theCam. Path , _T("http://10.0.0.8:80/jpg/image.jpg") );
_tcscpy(theCam. Type , _T("2100"));
theCam. Status = 0;
theCam. IO =1;
theCam. PTZ =0;
theCam.SaveMe ();
////////////////////////Add the server ip
HKEY hKey = NULL;
DWORD dwWord =0;
if(::RegCreateKeyEx(HKEY_CURRENT_USER, REGPATH, 0, NULL, 0, 0, NULL, &hKey, &dwWord) != ERROR_SUCCESS)
return;
TCHAR theServer[100];
_tcscpy(theServer, _T("158.132.152.111") );
::RegSetValueEx (hKey, _T("Server") , NULL, REG_MULTI_SZ, (LPBYTE)theServer, _tcslen(theServer)*sizeof(TCHAR) );
::RegCloseKey (hKey);
}
void CCamDesc::genHttpIpPrefix(TCHAR *rcUrl)
{
TCHAR *p;
p=wcsstr(this->Path , L"//");
p+=2;
p=wcschr(p, L'/');
p++;
TCHAR ch = *p;
*p=0;
_tcscpy(rcUrl, this->Path );
*p=ch;
}
BOOL CCamDesc::DeleteMeFromRegestry()
{
HKEY hKey = NULL;
DWORD dwWord =0;
if(::RegCreateKeyEx(HKEY_CURRENT_USER, REGPATH, 0, NULL, 0, 0, NULL, &hKey, &dwWord) != ERROR_SUCCESS)
return FALSE;
::RegDeleteKey (hKey, this->Name );
::RegCloseKey (hKey);
return TRUE;
}
void CCamDesc::getIPandPort(TCHAR *ip, int &port)
{
TCHAR tUrl[255];
TCHAR *p1, *p2, *p3;
_tcscpy(tUrl, this->Path);
p1=wcsstr(tUrl , L"//");
if(p1==NULL) p1 = tUrl; else p1+=2;
p2=wcschr(p1+1, L'/');
if(p2==NULL)
{
_tcscpy(ip, p1); port=80; return;
}
*p2=0;
p3=wcschr(p1, L':');
if(p3==NULL)
{
_tcscpy(ip, p1); port=80; return;
}
*p3=0;
_tcscpy(ip, p1);
char thePort[10];
memset(thePort, 0, 10);
p3++;
for(int i=0; *(p3+i); i++)
{
thePort[i] = (char) ( *(p3+i) );
}
port = atoi(thePort);
return;
}
void CCamDesc::getObjectName(TCHAR *obj)
{
TCHAR *p1;
p1=wcsstr(this->Path , L"//");
p1+=2;
p1=wcschr(p1, L'/');
if(p1 == NULL) { obj[0]=0; return; }
_tcscpy(obj, p1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -