📄 videocapture.cpp
字号:
// VideoCapture.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "VideoCapture.h"
#include "MainFrm.h"
#include "VideoCaptureDoc.h"
#include "VideoCaptureView.h"
#include "Mac.h"
#include "MyReg.h"
#define MutilProcess "34ECC119-3D1C-4513-81A5-25E6D05A748E"
#ifdef ROCKY
#include "ryvc32.h"
#endif
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//加密函数库(字符串加密) DeCode=TRUE加密false解密
typedef PCHAR (__stdcall * pPassWordCode)(PCHAR ByString,boolean DeCode= true);
/////////////////////////////////////////////////////////////////////////////
// CVideoCaptureApp
BEGIN_MESSAGE_MAP(CVideoCaptureApp, CWinApp)
//{{AFX_MSG_MAP(CVideoCaptureApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
ON_COMMAND(ID_VIEW_LOG, OnViewLog)
ON_COMMAND(ID_LOG_CLEAR, OnLogClear)
ON_COMMAND(ID_SYSTEM_CONFIG, OnSystemConfig)
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVideoCaptureApp construction
CVideoCaptureApp::CVideoCaptureApp()
{
m_unRegistMessage=::RegisterWindowMessage(MutilProcess);
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CVideoCaptureApp object
CVideoCaptureApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CVideoCaptureApp initialization
BOOL CVideoCaptureApp::InitInstance()
{
try
{
if (CopyFile(".\\Update.exe-Old",".\\Update.exe",FALSE))
DeleteFile(".\\Update.exe-Old");
}
catch (...) {
}
if (!AfxSocketInit())
{
AfxMessageBox("初始化网络Socket失败!");
return FALSE;
}
m_fCanGetSpeed=TRUE;
m_fSendDataToCom=FALSE;
m_fWaitRadar=FALSE;
m_fInitRadar=TRUE;
{//检查是否已经有程序的进程在运行
HANDLE m_hProtectedMultiProcess=::CreateMutex(NULL,true,MutilProcess);
if(GetLastError()==ERROR_ALREADY_EXISTS)
{
CloseHandle(m_hProtectedMultiProcess);
// 不做任何提示直接将旧程序推到最前
// MessageBox(NULL,"应用程序已经启动,按下【确定】进行激活!\n若无法激活,请打开\42Window任务管理器\42,在\42进程列表\42中找到\42VideoCapture.exe\42,然后点击\42结束进程\42按钮。\n接下来重新启动程序。",
// "运行程序出错",
// MB_OK|MB_ICONINFORMATION);
::BroadcastSystemMessage(BSF_POSTMESSAGE,NULL,m_unRegistMessage,0,0);
return false;
}
}
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
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
// SetRegistryKey(_T("Local AppWizard-Generated Applications"));
// LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CVideoCaptureDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CVideoCaptureView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
m_pMainWnd->UpdateWindow();
CString strTitle;
strTitle="便携式移动测速取证系统";
m_pMainWnd->SetWindowText(strTitle);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
public:
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
ON_WM_SHOWWINDOW()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CVideoCaptureApp::OnAppAbout()
{
CAboutDlg aboutDlg;
//KillTimer(AfxGetMainWnd()->m_hWnd,IDC_TIME_CAPTURE);
CVideoCaptureView* pView=CVideoCaptureView::GetView();
pView->IsCapturing=FALSE;
aboutDlg.DoModal();
// aboutDlg=new CAboutDlg();
// aboutDlg->Create(IDD_ABOUTBOX,AfxGetMainWnd());
// aboutDlg->ShowWindow(SW_SHOWNORMAL);
// aboutDlg->UpdateWindow();
}
void WriteLog(CString info)
{
CStdioFile* pTxtFile = new CStdioFile();
if(!pTxtFile->Open(".\\Log.Txt",CFile::modeReadWrite | CFile::typeText))
{
// MessageBox("Log.Txt文件不存在\n系统将新建该文件!",NULL,MB_OK|MB_ICONEXCLAMATION);
pTxtFile->Open(".\\Log.Txt",CFile::modeWrite | CFile::modeCreate);
}
pTxtFile->SeekToEnd();
COleDateTime time=COleDateTime::GetCurrentTime();
CString str;
str.Format("%4d-%2d-%2d %2d:%2d:%2d",time.GetYear(),time.GetMonth(),time.GetDay(),time.GetHour(),time.GetMinute(),time.GetSecond());
pTxtFile->WriteString(str+"------"+info+"\n");
pTxtFile->Close();
delete pTxtFile;
}
void ShowMessage(CString msg,UINT mb)
{
CVideoCaptureView* pView=CVideoCaptureView::GetView();
pView->IsCapturing=FALSE;
AfxMessageBox(msg,mb);
pView->IsCapturing=TRUE;
}
void ShowMessage2(CString msg,UINT mb)
{
CVideoCaptureView* pView=CVideoCaptureView::GetView();
pView->IsCapturing=FALSE;
AfxMessageBox(msg,mb);
}
/////////////////////////////////////////////////////////////////////////////
// CVideoCaptureApp message handlers
//查看日志
void CVideoCaptureApp::OnViewLog()
{
ShellExecute(NULL,"Open",".\\log.txt","","",SW_NORMAL);
}
//清除日志
void CVideoCaptureApp::OnLogClear()
{
CStdioFile f;
if(f.Open(".\\Log.Txt", CFile::modeCreate))
f.Close();
}
int CVideoCaptureApp::ExitInstance()
{
return CWinApp::ExitInstance();
}
void CAboutDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
CVideoCaptureView* pView=CVideoCaptureView::GetView();
pView->IsCapturing=TRUE;
GetDlgItem(IDC_STATIC_COM)->SetWindowText(GSMC);
}
void CVideoCaptureApp::OnSystemConfig()
{
ShellExecute(NULL,"Open","SetConfig.exe","","",SW_NORMAL);
}
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetWindowText("便携式移动测速取证系统");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -