实例介绍
【实例简介】
【Demo功能】
1、demo演示的功能有:局域网设备搜索、跨网段设备搜索、设备初始化、修改设备IP、设备密码找回
【注意事项】
1、编译环境为VS2005。
2、跨网段搜索只支持256个IP
3、修改IP暂不支持IPv6的修改
4、对设备进行初始化和密码找回操作需要确保本机IP和设备IP是同一局域网内,如果不在同一局域网,则会报超时错误
5、如需运行demo的exe文件,请将开发包中【库文件】里的全部dll文件拷贝至该工程目录下的bin/x86release或者bin/x64release下。
6、如把库文件放入程序生成的目录中,运行有问题,请到大华官网下载最新的网络SDK版本:http://www.dahuatech.com/index.php/service/downloadlists/836.html 替换程序中的库文件。
【实例截图】
【核心代码】
// DevInit.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "DevInit.h"
#include "DevInitDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDevInitApp
BEGIN_MESSAGE_MAP(CDevInitApp, CWinApp)
//{{AFX_MSG_MAP(CDevInitApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDevInitApp construction
TCHAR* g_GetIniPath(void)
{
static char pszIniPath[512] = {0};
if( strlen(pszIniPath) == 0 )
{
char szDirBuf[512] = {0};
GetCurrentDirectory(512, szDirBuf);
sprintf(pszIniPath, "%s\\langchn.ini", szDirBuf);
}
return pszIniPath;
}
CString ConvertString(CString strText)
{
char *val = new char[200];
CString strIniPath,strRet;
memset(val,0,200);
GetPrivateProfileString("String",strText,"",
val,200,g_GetIniPath());
strRet = val;
if(strRet.GetLength()==0)
{
//If there is no corresponding string in ini file ,then set it to be default value.
strRet=strText;
}
delete val;
return strRet;
}
//Set static text in dialogue box (English->current language)
void g_SetWndStaticText(CWnd * pWnd)
{
CString strCaption,strText;
//Set main window title
pWnd->GetWindowText(strCaption);
if(strCaption.GetLength()>0)
{
strText=ConvertString(strCaption);
pWnd->SetWindowText(strText);
}
//Set small window title
CWnd * pChild=pWnd->GetWindow(GW_CHILD);
CString strClassName;
while(pChild)
{
//////////////////////////////////////////////////////////////////////////
//Added by Jackbin 2005-03-11
strClassName = ((CRuntimeClass*)pChild->GetRuntimeClass())->m_lpszClassName;
if(strClassName == "CEdit")
{
//Next small window
pChild=pChild->GetWindow(GW_HWNDNEXT);
continue;
}
//////////////////////////////////////////////////////////////////////////
//Set small window current language text
pChild->GetWindowText(strCaption);
strText=ConvertString(strCaption);
pChild->SetWindowText(strText);
//Next small window
pChild=pChild->GetWindow(GW_HWNDNEXT);
}
}
CDevInitApp::CDevInitApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CDevInitApp object
CDevInitApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CDevInitApp initialization
BOOL CDevInitApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
CDevInitDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论