三星E848解手机话机锁程序

源代码在线查看: e848解锁dlg.cpp

软件大小: 68 K
上传用户: zhhw254774338
关键词: 三星 手机 话机 程序
下载地址: 免注册下载 普通下载 VIP

相关代码

				// E848解锁Dlg.cpp : implementation file
				//
				
				#include "stdafx.h"
				#include "E848解锁.h"
				#include "E848解锁Dlg.h"
				
				#ifdef _DEBUG
				#define new DEBUG_NEW
				#undef THIS_FILE
				static char THIS_FILE[] = __FILE__;
				#endif
				
				/////////////////////////////////////////////////////////////////////////////
				// 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)
					protected:
					virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
					//}}AFX_VIRTUAL
				
				// Implementation
				protected:
					//{{AFX_MSG(CAboutDlg)
					//}}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)
					//}}AFX_MSG_MAP
				END_MESSAGE_MAP()
				
				/////////////////////////////////////////////////////////////////////////////
				// CE848Dlg dialog
				LONG CE848Dlg::OnComm(WPARAM ch, LPARAM port)
				{
					if(port==1)   //串口的数据处理
					{
						m_strPortRXData[js] = ch;
						if(m_strPortRXData[0]==0x01)
						{
							js++;
							if(js>26 && m_strPortRXData[1]==0xfc)
							{
								js=0;
								KillTimer(1);
								m_SerialPort.ClosePort();
								AfxMessageBox("密码恢复为8个0 ! \r\n 重新开机输入  ");
							}	
						}
					}
				
					return 0;
				}
				CE848Dlg::CE848Dlg(CWnd* pParent /*=NULL*/)
					: CDialog(CE848Dlg::IDD, pParent)
				{
					//{{AFX_DATA_INIT(CE848Dlg)
						// NOTE: the ClassWizard will add member initialization here
					//}}AFX_DATA_INIT
					// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
					m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
				}
				
				void CE848Dlg::DoDataExchange(CDataExchange* pDX)
				{
					CDialog::DoDataExchange(pDX);
					//{{AFX_DATA_MAP(CE848Dlg)
						// NOTE: the ClassWizard will add DDX and DDV calls here
					//}}AFX_DATA_MAP
				}
				
				BEGIN_MESSAGE_MAP(CE848Dlg, CDialog)
					//{{AFX_MSG_MAP(CE848Dlg)
					ON_WM_SYSCOMMAND()
					ON_WM_PAINT()
					ON_WM_QUERYDRAGICON()
					ON_MESSAGE(WM_COMM_RXCHAR, OnComm)
					ON_WM_TIMER()
					ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
					ON_WM_DESTROY()
					//}}AFX_MSG_MAP
				END_MESSAGE_MAP()
				
				/////////////////////////////////////////////////////////////////////////////
				// CE848Dlg message handlers
				
				BOOL CE848Dlg::OnInitDialog()
				{
					CDialog::OnInitDialog();
				
					// Add "About..." menu item to system menu.
				
					// IDM_ABOUTBOX must be in the system command range.
					ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
					ASSERT(IDM_ABOUTBOX < 0xF000);
				
					CMenu* pSysMenu = GetSystemMenu(FALSE);
					if (pSysMenu != NULL)
					{
						CString strAboutMenu;
						strAboutMenu.LoadString(IDS_ABOUTBOX);
						if (!strAboutMenu.IsEmpty())
						{
							pSysMenu->AppendMenu(MF_SEPARATOR);
							pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
						}
					}
				
					// Set the icon for this dialog.  The framework does this automatically
					//  when the application's main window is not a dialog
					SetIcon(m_hIcon, TRUE);			// Set big icon
					SetIcon(m_hIcon, FALSE);		// Set small icon
					
					// TODO: Add extra initialization here
						
					return TRUE;  // return TRUE  unless you set the focus to a control
				}
				
				void CE848Dlg::OnSysCommand(UINT nID, LPARAM lParam)
				{
					if ((nID & 0xFFF0) == IDM_ABOUTBOX)
					{
						CAboutDlg dlgAbout;
						dlgAbout.DoModal();
					}
					else
					{
						CDialog::OnSysCommand(nID, lParam);
					}
				}
				
				// If you add a minimize button to your dialog, you will need the code below
				//  to draw the icon.  For MFC applications using the document/view model,
				//  this is automatically done for you by the framework.
				
				void CE848Dlg::OnPaint() 
				{
					if (IsIconic())
					{
						CPaintDC dc(this); // device context for painting
				
						SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
				
						// Center icon in client rectangle
						int cxIcon = GetSystemMetrics(SM_CXICON);
						int cyIcon = GetSystemMetrics(SM_CYICON);
						CRect rect;
						GetClientRect(&rect);
						int x = (rect.Width() - cxIcon + 1) / 2;
						int y = (rect.Height() - cyIcon + 1) / 2;
				
						// Draw the icon
						dc.DrawIcon(x, y, m_hIcon);
					}
					else
					{
						CDialog::OnPaint();
					}
				}
				
				// The system calls this to obtain the cursor to display while the user drags
				//  the minimized window.
				HCURSOR CE848Dlg::OnQueryDragIcon()
				{
					return (HCURSOR) m_hIcon;
				}
				
				void CE848Dlg::OnCancel() 
				{
					// TODO: Add extra cleanup here
					
					CDialog::OnCancel();
				}
				
				void CE848Dlg::OnTimer(UINT nIDEvent) 
				{
					// TODO: Add your message handler code here and/or call default
					CString senddata;
					senddata="00 53 65 74 4D 6D 69 4E 56 4D 43 6F 6E 74 65 6E 74 73 2C 4C 4F 43 4B 50 57 44 2C 34 38 2C 34 38 2C 34 38 2C 34 38 2C 34 38 2C 34 38 2C 34 38 2C 34 38 2C 30 16";
					char data[512];
					int len=String2Hex(senddata,data);
					
					m_SerialPort.WriteToPort(data,len);
					js1++;
					if(js1>10)
					{
						KillTimer(1);  //取消定时
						m_SerialPort.ClosePort();
						AfxMessageBox("解锁失败 ! ");
					}
					CDialog::OnTimer(nIDEvent);
				}
				
				void CE848Dlg::OnButton1() 
				{
					if(m_SerialPort.InitPort(this, 1, 115200,'N',8,1,EV_RXFLAG | EV_RXCHAR,512))
						{
							m_SerialPort.StartMonitoring();
						}
						else
						{
							AfxMessageBox("没有发现此串口或被占用");
						}
					js1=0;
					js=0;
					SetTimer(1,80,NULL);//时间为1000毫秒	
				}
				
				int CE848Dlg::String2Hex(CString str, char* data)
				{
					int t,t1;
					int rlen=0,len=str.GetAllocLength();
					for(int i=0;i					{
						char l,h=str[i];
						if (h==' ')
						{
							i++;
							continue;
						}
						i++;
						if(i>=len) break;
						l=str[i];
						t=HexChar(h);
						t1=HexChar(l);
						if((t==16)||(t1==16)) break;
						else
							t=t*16+t1;
						i++;
							data[rlen]=(char)t;
							rlen++;
					}
					return rlen;
				}
				
				char CE848Dlg::HexChar(char ch)
				{
					if((ch>='0')&&(ch					else if((ch>='A')&&(ch					else if((ch>='a')&&(ch					else return (0x10);
				}
				
				void CE848Dlg::OnDestroy() 
				{
					CDialog::OnDestroy();
					
					// TODO: Add your message handler code here
					m_SerialPort.ClosePort();
					KillTimer(1);
				}
							

相关资源