📄 softprotected.cpp
字号:
// SoftProtected.cpp : implementation file
//
#include "stdafx.h"
#include "PPPClient.h"
#include "SoftProtected.h"
#include "pppclientdlg.h"
extern CPPPClientDlg *m_main_dlg;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSoftProtected dialog
CSoftProtected::CSoftProtected(CWnd* pParent /*=NULL*/)
: CDialog(CSoftProtected::IDD, pParent)
{
//{{AFX_DATA_INIT(CSoftProtected)
m_lc_str = _T("");
//}}AFX_DATA_INIT
}
void CSoftProtected::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSoftProtected)
DDX_Text(pDX, IDC_LC_EDIT, m_lc_str);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSoftProtected, CDialog)
//{{AFX_MSG_MAP(CSoftProtected)
ON_BN_CLICKED(IDC_EXIT_BUTTON, OnExitButton)
ON_BN_CLICKED(IDC_UNLOCKED_BUTTON, OnUnlockedButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSoftProtected message handlers
void CSoftProtected::OnExitButton()
{
// TODO: Add your control notification handler code here
EndDialog(0);
}
//
BOOL CSoftProtected::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_ESCAPE) return TRUE;
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN) return TRUE;
return CDialog::PreTranslateMessage(pMsg);
}
//
BOOL CSoftProtected::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
GetDlgItem(IDC_STATUS_EDIT)->SetWindowText(TEXT("Unknow"));
GetDlgItem(IDC_LSN_EDIT)->SetWindowText(TEXT("Unknow "));
GetDlgItem(IDC_LC_EDIT)->SetWindowText(TEXT(""));
//m_server_code_str=TEXT("Unknow Code");
//m_server_sn_str=TEXT("");
GetDlgItem(IDC_LC_EDIT)->EnableWindow(TRUE);
GetDlgItem(IDC_UNLOCKED_BUTTON)->EnableWindow(TRUE);
//get server code and register
char did[16];//16 effect
CString m_sn_str,tmp_str;
DWORD m_rest_time;
BOOL m_time_flag;
memset(did,0x00,sizeof(did));
if(m_main_dlg->GetSoftProtectedID(did))
{
m_sn_str="";
for(int i=0;i<16;i++)
{
tmp_str.Format("%02X",(BYTE)did[i]);
m_sn_str=m_sn_str+tmp_str;
}
GetDlgItem(IDC_LSN_EDIT)->SetWindowText(m_sn_str);
//m_server_code_str=did; //
if(m_main_dlg->GetSoftProtectedStatus(m_time_flag,m_rest_time))
{
if(!m_time_flag&&m_rest_time==0)
{
GetDlgItem(IDC_STATUS_EDIT)->SetWindowText(TEXT("Times Ok"));
GetDlgItem(IDC_LC_EDIT)->EnableWindow(FALSE);
GetDlgItem(IDC_UNLOCKED_BUTTON)->EnableWindow(FALSE);
GetDlgItem(IDC_LC_EDIT)->SetWindowText(TEXT(""));
}
else
{ //
CString str;
str.Format("%ld",m_rest_time);
GetDlgItem(IDC_STATUS_EDIT)->SetWindowText(str);
GetDlgItem(IDC_LC_EDIT)->EnableWindow(TRUE);
GetDlgItem(IDC_UNLOCKED_BUTTON)->EnableWindow(TRUE);
}
}
}
//UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//
void CSoftProtected::OnUnlockedButton()
{
// TODO: Add your control notification handler code here
UpdateData();
char data[256];
strcpy(data,m_lc_str.GetBuffer(m_lc_str.GetLength()));
if(m_main_dlg->SetSoftProtectedSN(data))
{
GetDlgItem(IDC_STATUS_EDIT)->SetWindowText(TEXT("Times Ok"));
GetDlgItem(IDC_LC_EDIT)->EnableWindow(FALSE);
GetDlgItem(IDC_UNLOCKED_BUTTON)->EnableWindow(FALSE);
}
else
{
GetDlgItem(IDC_STATUS_EDIT)->SetWindowText(TEXT("Unknow"));
GetDlgItem(IDC_LC_EDIT)->EnableWindow(TRUE);
GetDlgItem(IDC_UNLOCKED_BUTTON)->EnableWindow(TRUE);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -