123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773 |
- // AutoRun3Dlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "AutoRun3.h"
- #include "AutoRun3Dlg2.h"
- #include <afxsock.h>//<Winsock2.h>
- #include "ConnectDlg.h"
- #include "SendDataDlg.h"
- #include "AddContact.h"
- #include "SendReg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- extern DWORD g_nSendCode;
- extern BOOL g_bReturned2;
- /////////////////////////////////////////////////////////////////////////////
- extern HWND g_hSendWnd;
- extern HWND g_hConnectWnd;
- #define DISCONNECT_TIMER (WM_USER + 101)
- #define LOGINFAILED_TIMER (WM_USER + 102)
- /////////////////////////////////////////////////////////////////////////////
- static void HandleClientNetEvent2(IN SOCKET hSocket, IN ETransportEvent eEvent,
- IN void *pDataBuf, IN unsigned long nDataLen,
- IN int nError, IN void *pContext)
- {
- if( nError != TRANSPORT_OK ) return;
- CAutoRun3Dlg2 *pDlg = (CAutoRun3Dlg2 *)pContext;
- if( NULL == pDlg ) return;
- pDlg->ProcessNetEvent(eEvent, pDataBuf, nDataLen);
- }
- CAutoRun3Dlg2::CAutoRun3Dlg2(CWnd* pParent /*=NULL*/)
- : CDialog(CAutoRun3Dlg2::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CAutoRun3Dlg2)
- m_strSendSms = _T("");
- m_strLoginID = _T("");
- m_strLoginPwd = _T("");
- m_strRecvMobi = _T("");
- m_strNewPwd = _T("");
- m_mobicount = 0;
- m_check1 = FALSE;
- m_count = 0;
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_nMobile=0;
- m_nPhone=0;
- CString version = _T ("Version 1.0");
- m_strLoginID=AfxGetApp()->GetProfileString (version, "account", "");
- m_strLoginPwd=AfxGetApp()->GetProfileString (version, "psw", "");
- if(!m_strLoginPwd.IsEmpty())m_check1=1;
- }
- void CAutoRun3Dlg2::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAutoRun3Dlg2)
- DDX_Control(pDX, IDC_LIST2, m_List1);
- DDX_Control(pDX, IDC_BTN_SEND, m_btnSend);
- DDX_Control(pDX, IDC_LST_SMS, m_listCtrl);
- DDX_Text(pDX, IDC_EDT_SMS, m_strSendSms);
- DDV_MaxChars(pDX, m_strSendSms, 2000);
- DDX_Text(pDX, IDC_EDT_LOGIN_ID, m_strLoginID);
- DDV_MaxChars(pDX, m_strLoginID, 11);
- DDX_Text(pDX, IDC_EDT_LOGIN_PWD, m_strLoginPwd);
- DDX_Text(pDX, IDC_EDT_RECV_MOBI, m_strRecvMobi);
- DDX_Text(pDX, IDC_EDT_NEW_PWD, m_strNewPwd);
- DDX_Text(pDX, IDC_EDT_NUM, m_mobicount);
- DDX_Check(pDX, IDC_CHECK1, m_check1);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CAutoRun3Dlg2, CDialog)
- //{{AFX_MSG_MAP(CAutoRun3Dlg2)
- ON_WM_DESTROY()
- ON_BN_CLICKED(IDC_BTN_SEND, OnBtnSend)
- ON_BN_CLICKED(IDC_BTN_QUERY, OnBtnQuery)
- ON_BN_CLICKED(IDC_BTN_Query2, OnBTNQuery2)
- ON_BN_CLICKED(IDC_BTN_CHANGE_PWD, OnBtnChangePwd)
- ON_BN_CLICKED(IDC_BTN_GET_STATUS, OnBtnGetStatus)
- ON_WM_TIMER()
- ON_BN_CLICKED(IDC_BUTadd, OnBUTadd)
- ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
- ON_LBN_SELCHANGE(IDC_LIST2, OnSelchangeList2)
- ON_EN_CHANGE(IDC_EDT_SMS, OnChangeEdtSms)
- ON_EN_CHANGE(IDC_EDT_RECV_MOBI, OnChangeEdtRecvMobi)
- ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
- ON_BN_CLICKED(IDC_BTN_REG, OnBtnReg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- BOOL CAutoRun3Dlg2::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // Set the icon for this dialog. The framework does this automatically
- // when the application's main window is not a dialog
-
- // g_pMainWnd=this;
- /////////////////////////////////
- // TODO: Add extra initialization here
- return TRUE; // return TRUE unless you set the focus to a control
- }
- DWORD CAutoRun3Dlg2::GetConnectionID()
- {
- return m_dwConnectionID;
- }
- void CAutoRun3Dlg2::SetConnectionID(DWORD dwConnection)
- {
- m_dwConnectionID = dwConnection;
- }
- void CAutoRun3Dlg2::ProcessChatMessageRequest2(CString sql)
- {
- const char *szDataBuf = sql.GetBuffer(0);
- sql.ReleaseBuffer();
- ProcessChatMessageRequest((void*)szDataBuf, strlen(szDataBuf) + 1);
- }
- void CAutoRun3Dlg2::ProcessChatMessageRequest2(BYTE code)
- {
- ProcessChatMessageRequest(&code, sizeof(BYTE));
- }
- void CAutoRun3Dlg2::ProcessChatMessageRequest2(BYTE *pData, int length)
- {
- ProcessChatMessageRequest((void*)pData, length);
- }
- BOOL CAutoRun3Dlg2::ProcessChatMessageRequest(void *szDataBuf, int nDataLen)
- {
- g_bReturned2=0;
- DWORD dwFromUserID = GetConnectionID();
- WORD wMessageId = MSG_CHATMESSAGE_REQ;
- DWORD dwDataLen = sizeof(TCHAT_MESSAGE_STRU) + nDataLen;
- BYTE *pSendData = new BYTE[dwDataLen];
- TCHAT_MESSAGE_STRU *pChatMessage=(TCHAT_MESSAGE_STRU*)pSendData;
- memset(pChatMessage, 0x00, dwDataLen);
- g_sendhead.length[98]=987123768;
- memcpy(pSendData, &g_sendhead, sizeof(g_sendhead));
- pChatMessage->tCommonMsg.dwConnectionID = GetConnectionID();
- pChatMessage->tCommonMsg.wMessageId = wMessageId;
- pChatMessage->dwFromUserID = dwFromUserID;
- pChatMessage->dwToUserID = 15;
- pChatMessage->wMessageLen = nDataLen;
- memcpy(pChatMessage->byFileContent, szDataBuf, nDataLen);
-
- TMessageHeader tHeader = {0};
- tHeader.wMessageId = wMessageId;
- tHeader.dwDataLen = dwDataLen;
- BOOL bRet=0;
- unsigned long ulSendLen = m_tClientTunnel.net_Send(&tHeader, (void *)pChatMessage, dwDataLen);
- if( ulSendLen != SOCKET_ERROR )
- {
- bRet=1;
- }
- delete [] pSendData;
- return bRet;
- }
- BOOL CAutoRun3Dlg2::OnConnect()
- {
- CString strServerAddress = g_server2;
- char *szServerAddress = strServerAddress.GetBuffer(0);
- strServerAddress.ReleaseBuffer();
- /*for Client, IP and Port can be 0,
- and for Server, IP is LocalIP, and Port is Listening Port*/
- int nResult = m_tClientTunnel.net_OpenSocket(Transport_Client,
- 0,
- HandleClientNetEvent2,
- this);
- if( TRANSPORT_OK != nResult )
- {
- return 0;
- }
- DWORD dwRemoteIPValue = inet_addr(szServerAddress);
- WORD wPort = 5678;
- nResult = m_tClientTunnel.net_Connect(dwRemoteIPValue, wPort);
- if( TRANSPORT_OK != nResult )
- {
- m_tClientTunnel.net_CloseSocket();
- return 0;
- }
- return ProcessLoginRequest();
- }
- void CAutoRun3Dlg2::ProcessNetEvent(int nEventType, void *pRecvMsg, DWORD dwDataLen)
- {
- if( Transport_ReadEv == nEventType )
- {
- if( NULL == pRecvMsg ) return;
- TMessageHeader* pHeader = (TMessageHeader *)pRecvMsg;
- char *pDataBuf = (char *)pRecvMsg + MESSAGE_HEADER_LEN;
- WORD dwMessageID = pHeader->wMessageId;
- switch(dwMessageID)
- {
- case MSG_LOGIN_RESP:
- {
- LOGIN_RESULT_STRU tLoginResult = {0};
- memcpy(&tLoginResult, pDataBuf, sizeof(LOGIN_RESULT_STRU));
-
- ProcessLoginResponse(&tLoginResult);
- break;
- }
- case MSG_USERINFO_RESP:
- {
- TUSERLIST_INFO_STRU tUserListInfo = {0};
- memcpy(&tUserListInfo, pDataBuf, sizeof(TUSERLIST_INFO_STRU));
- // ProcessUserListInfoResponse(&tUserListInfo);
- break;
- }
- case MSG_LOGOUT_RESP:
- {
- TUSERLIST_INFO_STRU tUserListInfo = {0};
- memcpy(&tUserListInfo, pDataBuf, sizeof(TUSERLIST_INFO_STRU));
- // ProcessLogoutResponse(&tUserListInfo);
- break;
- }
- case MSG_CHATMESSAGE_RESP:
- {
- TCHAT_MESSAGE_STRU *pChatMessage = (TCHAT_MESSAGE_STRU *)pDataBuf;
-
- ProcessChatMessageResponse((void *)pChatMessage);
- break;
- }
- default:
- {
- break;
- }
- }
- }
- else if( Transport_CloseEv == nEventType )
- {
- SetTimer(DISCONNECT_TIMER, 0, NULL);
- }
- ///////
- }
- void CAutoRun3Dlg2::OnDisconnect()
- {
- m_tClientTunnel.net_CloseSocket();
- SetConnectionID(INVALID_SOCKET);
- }
- void CAutoRun3Dlg2::ProcessLoginResponse(void *pLoginResult)
- {
- if( NULL == pLoginResult ) return;
- LOGIN_RESULT_STRU *ptLoginResult = (LOGIN_RESULT_STRU *)pLoginResult;
- DWORD dwConnectionID = ptLoginResult->tCommonMsg.dwConnectionID;
- SetConnectionID(dwConnectionID);
- BYTE byResult = ptLoginResult->byResult;
- if(LOGIN_RESULT_SUC == byResult)
- {
- }
- else
- {
- SetTimer(LOGINFAILED_TIMER, 0, NULL);
- }
- CString strCommentInfo("");
- strCommentInfo.Format("%s. 用户代号: %ld",
- ((LOGIN_RESULT_SUC == byResult) ? "登录成功" :
- (LOGIN_RESULT_MULTI == byResult) ? "重复登录" :
- (LOGIN_RESULT_NAMERROR == byResult) ? "名字不存在" :
- (LOGIN_RESULT_PWERROR == byResult) ? "密码错误" : "登录失败"),
- dwConnectionID);
- // MessageBox((CString)strCommentInfo);
- }
- extern void MyGetIPByName(CString &name);
- extern CString g_localip;
- BOOL CAutoRun3Dlg2::ProcessLoginRequest()
- {
- WORD wMessageId = MSG_LOGIN_REQ;
- TLOGIN_STRU tLogonInfo = {0};
- tLogonInfo.tCommonMsg.dwConnectionID = GetConnectionID();
- tLogonInfo.tCommonMsg.wMessageId = wMessageId;
- if(g_localip.IsEmpty ())
- {
- char path[MAX_PATH];
- ::memset (path, 0, MAX_PATH);
- DWORD leng=50;
- ::GetComputerName (path, &leng);
- g_localip=path;
- MyGetIPByName(g_localip);
- return 0;
- }
- CString strUserName = "rtghj3wsdfg"+g_localip;
-
- strUserName.TrimLeft();
- strUserName.TrimRight();
- strcpy(tLogonInfo.tUserInfo.szUserName, strUserName);
-
- DWORD dwDataLen = sizeof(TLOGIN_STRU);
- TMessageHeader tHeader = {0};
- tHeader.wMessageId = wMessageId;
- tHeader.dwDataLen = dwDataLen;
- unsigned long ulSendLen = m_tClientTunnel.net_Send(&tHeader, (void *)&tLogonInfo, dwDataLen);
- if( ulSendLen == SOCKET_ERROR )
- {
- return 0;
- }
- return 1;
- }
- //---------------------------------------------------------------------------
- void CAutoRun3Dlg2::OnDestroy()
- {
- CDialog::OnDestroy();
- OnDisconnect();
- }
- void CAutoRun3Dlg2::OnTimer(UINT nIDEvent)
- {
- // TODO: Add your message handler code here and/or call default
- if( DISCONNECT_TIMER == nIDEvent )
- {
- KillTimer(nIDEvent);
- OnDisconnect();
- }
- else if( LOGINFAILED_TIMER == nIDEvent )
- {
- KillTimer(nIDEvent);
- OnDisconnect();
- }
-
- }
- void CAutoRun3Dlg2::OnBUTadd()
- {
- // TODO: Add your control notification handler code here
- AddContact dlg;
- if(dlg.DoModal ()!=IDOK)return;
- CString str;
- int pos;
- for(int i=0; i<m_List1.GetCount (); i++)
- {
- m_List1.GetText (i, str);
- pos=str.Find ("\r\n");
- if(dlg.m_phone==str.Right (str.GetLength ()-pos-2))
- {
- AfxMessageBox("已有此电话的记录!");
- return;
- }
- }
- CString sql;
- sql= "insert into contact([name],[phone]) values(\
- '"+dlg.m_name+"',\
- '"+dlg.m_phone+"')";
- g_db.ExecuteSQL (sql);
- if(m_List1.GetCount()%2)
- m_List1.AddEntry( dlg.m_name+"\r\n"+dlg.m_phone , RGB(240,247,255), m_List1.GetCount());
- else
- m_List1.AddEntry( dlg.m_name+"\r\n"+dlg.m_phone , RGB(255,248,240), m_List1.GetCount());
- }
- void CAutoRun3Dlg2::OnBUTdel()
- {
- // TODO: Add your control notification handler code here
- int listpos=m_List1.GetCurSel ();
- if(listpos==-1)
- {
- AfxMessageBox("请先选中您要删除的联系人!");
- return;
- }
- if(AfxMessageBox("警告:删除后将不可恢复, 继续吗?", MB_YESNO|MB_ICONSTOP)!=IDYES)return;
- CString str;
- m_List1.GetText (listpos, str);
- int pos=str.Find ("\r\n");
- CString name=str.Left (pos);
- CString phone=str.Right (str.GetLength ()-pos-2);
- CString sql;
- sql= "delete from contact where [name]='"+name+"' and [phone]='"+phone+"'";
- g_db.ExecuteSQL (sql);
- m_List1.DeleteString(listpos);
- }
- void CAutoRun3Dlg2::OnSelchangeList2()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- int count= m_List1.GetSelCount() ;
- if(count==0)return;
- int *pIndex=new int[count];
- m_List1.GetSelItems(count, pIndex);
- m_strRecvMobi = _T("");
- m_mobicount = 0;
- CString str;
- int pos;
- m_nMobile=0;
- m_nPhone=0;
- for(int i=0; i<count; i++)
- {
- m_List1.GetText (pIndex[i], str);
- pos=str.Find ("\r\n");
- if(CheckPhoneType(str.Right (str.GetLength ()-pos-2))==0)
- m_nMobile++;
- else if(CheckPhoneType(str.Right (str.GetLength ()-pos-2))==1)
- m_nPhone++;
- else
- {
- AfxMessageBox("号码"+str.Right (str.GetLength ()-pos-2)+"不是正确的电话号码!", MB_ICONSTOP);
- continue;
- }
- m_strRecvMobi+=str.Right (str.GetLength ()-pos-2);
- m_strRecvMobi+=",";
- m_mobicount++;
- }
- m_strRecvMobi.TrimRight (",");
- UpdateData(false);
- delete []pIndex;
- OnChangeEdtSms();
- }
- int CAutoRun3Dlg2::CheckPhoneType(CString phoneno)
- {
- for(int i=0; i<phoneno.GetLength (); i++)
- {
- if(phoneno.GetAt (i)<'0'||phoneno.GetAt (i)>'9')return -1;
- }
- if(phoneno.GetAt (0)=='1')
- {
- if(phoneno.GetLength ()!=11)
- return -1;
- int mobile[]={139,138,137,136,135,134,159,158,152,151,150,157,188,187,144};
- int unicom[]={130,131,132,155,156,186,185};
- int telecom[]={133,153,189,180};
- BOOL bFind=0;
- for(i=0; i<sizeof(mobile)/sizeof(int); i++)
- {
- if(mobile[i]==atoi(phoneno.Left (3)))
- {
- bFind=1;
- break;
- }
- }
- for(i=0; i<sizeof(unicom)/sizeof(int); i++)
- {
- if(unicom[i]==atoi(phoneno.Left (3)))
- {
- bFind=1;
- break;
- }
- }
- for(i=0; i<sizeof(telecom)/sizeof(int); i++)
- {
- if(telecom[i]==atoi(phoneno.Left (3)))
- {
- bFind=1;
- break;
- }
- }
- if(!bFind)
- return -1;
- else
- {
- // m_nMobile++;
- return 0;
- }
- }
- else if(phoneno.GetAt (0)=='0')
- {
- if(phoneno.GetLength ()>=10 && phoneno.GetLength ()<=12)
- {
- // m_nPhone++;
- return 1;
- }
- }
- return -1;
- }
- void CAutoRun3Dlg2::OnChangeEdtRecvMobi()
- {
- // TODO: If this is a RICHEDIT control, the control will not
- // send this notification unless you override the CDialog::OnInitDialog()
- // function and call CRichEditCtrl().SetEventMask()
- // with the ENM_CHANGE flag ORed into the mask.
-
- // TODO: Add your control notification handler code here
-
- }
- void CAutoRun3Dlg2::OnChangeEdtSms()
- {
- // TODO: If this is a RICHEDIT control, the control will not
- // send this notification unless you override the CDialog::OnInitDialog()
- // function and call CRichEditCtrl().SetEventMask()
- // with the ENM_CHANGE flag ORed into the mask.
- UpdateData();
- m_strSendSms.Replace ("'", "'");
- m_strSendSms.Replace ("(", "(");
- m_strSendSms.Replace (")", ")");
- SetDlgItemText(IDC_EDT_SMS, m_strSendSms);
- ((CEdit*)GetDlgItem(IDC_EDT_SMS))->SetSel(m_strSendSms.GetLength (),m_strSendSms.GetLength ());
- CString str;
- int count=0;
- int leng=GetLengthEx(m_strSendSms);
- if(m_nMobile)
- {
- count+=m_nMobile*(leng/70);
- if(leng%70)
- count+=m_nMobile;
- }
- if(m_nPhone)
- {
- count+=m_nPhone*(leng/56);
- if(leng%56)
- count+=m_nPhone;
- }
- m_count=count;
- str.Format ("短信内容(手机70字/条,小灵通56字/条)(现%d字,共%d条短信)", leng,count);
- GetDlgItem(IDC_STATIC1)->SetWindowText(str);
- // TODO: Add your control notification handler code here
-
- }
- int CAutoRun3Dlg2::GetLengthEx(CString str)
- {
- int leng=0;
- TBYTE ucHigh, ucLow;
- for (int i=0; i<str.GetLength(); i++)
- {
- if ( (TBYTE)str[i] < 0x80 )
- {
- leng++;
- continue;
- }
- ucHigh = (TBYTE)str[i];
- ucLow = (TBYTE)str[i+1];
- if ( ucHigh < 0xa1 || ucLow < 0xa1)
- {
- leng++;
- continue;
- }
- leng++;
- i++;
- }
- return leng;
- }
- //---------------------------------------------------------------------------
- void CAutoRun3Dlg2::OnBtnSend()
- {
- UpdateData();
- if(m_mobicount==0)
- {
- AfxMessageBox("手机号码不能为空, 请在联系人中选择, 按Ctrl或Shift键多选!");
- return;
- }
- if(m_strSendSms.IsEmpty ())
- {
- AfxMessageBox("信息不能为空!");
- return;
- }
- if(m_strLoginID.IsEmpty ())
- {
- AfxMessageBox("账号不能为空!");
- return;
- }
- if(m_strLoginPwd.IsEmpty ())
- {
- AfxMessageBox("密码不能为空!");
- return;
- }
- CString str,timestamp;
- timestamp=CTime::GetCurrentTime ().Format ("%Y%m%d%H%M%S");
- str=m_strLoginID;
- str+="\r\n";
- str+=m_strLoginPwd;
- str+="\r\n";
- str+=m_strRecvMobi;
- str+="\r\n";
- str+=m_strSendSms;
- str+="\r\n";
- str+=timestamp;
- if(CheckExist(m_strSendSms,m_strRecvMobi))
- {
- if(AfxMessageBox("提醒:相似的信息已发送, 重复发送将再次收取短信费用, 继续吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
- }
- CString scount;
- scount.Format ("%d", m_count);
- CString sql="insert into sendreg([account],[phones],[content],[timestamp],[msgcount],[status]) values\
- ('"+m_strLoginID+"','"+m_strRecvMobi+"','"+m_strSendSms+"','"+timestamp+"','"+scount+"','0')";
- if(!MyExecuteSQL(&g_db, sql))
- {
- AfxMessageBox("保存信息失败,请联系管理员!");
- return;
- }
- BYTE *pData=new BYTE[str.GetLength ()];
- memcpy(pData, str.GetBuffer (0), str.GetLength ());
- str.ReleaseBuffer ();
- EncryptFile2(pData, str.GetLength (), "888666333");
- g_nSendCode=0;
- ProcessChatMessageRequest2(pData, str.GetLength ());
- g_nSendCode=0;
- delete []pData;
- if(g_bSendOK==0)
- {
- sql="delete from sendreg where [account]='"+m_strLoginID+"' and \
- [timestamp]='"+timestamp+"'";
- MyExecuteSQL(&g_db, sql);
- return;
- }
- }
- void CAutoRun3Dlg2::OnCheck1()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- }
- //---------------------------------------------------------------------------
- void CAutoRun3Dlg2::OnBtnQuery() //查询余额
- {
- UpdateData();
- CString str;
- str=m_strLoginID;
- str+="\r\n";
- str+=m_strLoginPwd;
- BYTE *pData=new BYTE[str.GetLength ()];
- memcpy(pData, str.GetBuffer (0), str.GetLength ());
- str.ReleaseBuffer ();
- EncryptFile2(pData, str.GetLength (), "888666333");
- g_nSendCode=3;
- ProcessChatMessageRequest2(pData, str.GetLength ());
- g_nSendCode=0;
- delete []pData;
- }
- //---------------------------------------------------------------------------
- void CAutoRun3Dlg2::OnBTNQuery2()//查询使用
- {
- UpdateData();
- CString str;
- str=m_strLoginID;
- str+="\r\n";
- str+=m_strLoginPwd;
- BYTE *pData=new BYTE[str.GetLength ()];
- memcpy(pData, str.GetBuffer (0), str.GetLength ());
- str.ReleaseBuffer ();
- EncryptFile2(pData, str.GetLength (), "888666333");
- g_nSendCode=2;
- ProcessChatMessageRequest2(pData, str.GetLength ());
- g_nSendCode=0;
- delete []pData;
- }
- void CAutoRun3Dlg2::OnBtnChangePwd()
- {
- UpdateData();
- if(m_strNewPwd.IsEmpty ())
- {
- AfxMessageBox("请输入新密码!");
- return;
- }
- if(m_strNewPwd.GetLength ()>20)m_strNewPwd=m_strNewPwd.Left (20);
- CString str;
- str=m_strLoginID;
- str+="\r\n";
- str+=m_strLoginPwd;
- str+="\r\n";
- str+=m_strNewPwd;
- BYTE *pData=new BYTE[str.GetLength ()];
- memcpy(pData, str.GetBuffer (0), str.GetLength ());
- str.ReleaseBuffer ();
- EncryptFile2(pData, str.GetLength (), "888666333");
- g_nSendCode=1;
- ProcessChatMessageRequest2(pData, str.GetLength ());
- g_nSendCode=0;
- delete []pData;
- }
- void CAutoRun3Dlg2::OnBtnGetStatus()
- {
- }
- BOOL CAutoRun3Dlg2::MyExecuteSQL(CDatabase *pdb, CString sql)
- {
- try
- {
- pdb->ExecuteSQL (sql);
- }
- catch(...)
- {
- return 0;
- }
- return 1;
- }
- BOOL CAutoRun3Dlg2::CheckExist(CString content, CString phones)
- {
- CRecordset myset(&g_db);
- CString sql="select count(*) as cot from sendreg where [content]='"+content+"' and [phones]='"+phones+"'";
- myset.Open (CRecordset::forwardOnly, sql);
- if(!myset.IsEOF())
- {
- myset.GetFieldValue ("cot", sql);
- if(atoi(sql))
- return 1;
- else
- return 0;
- }
- else
- return 0;
- }
- void CAutoRun3Dlg2::OnBtnReg()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- SendReg dlg;
- dlg.m_strLoginID=m_strLoginID;
- dlg.m_strLoginPwd=m_strLoginPwd;
- dlg.DoModal ();
- }
- extern CArray<CStringArray, CStringArray>g_List1array;
- extern DWORD g_nLeng;
- extern BYTE *g_pData;
- extern DWORD g_ncount2;
- void CAutoRun3Dlg2::ProcessChatMessageResponse(void *pResponse)
- {
- if( NULL == pResponse ) return;
- TCHAT_MESSAGE_STRU *pChatMessage = (TCHAT_MESSAGE_STRU *)pResponse;
- int nMessageLen = pChatMessage->wMessageLen;
- // if(nMessageLen==0)
- // return;
- if(g_pData)delete []g_pData;g_pData=NULL;
- g_pData=new BYTE[nMessageLen];
- memcpy(g_pData, pChatMessage->byFileContent, nMessageLen);
- memcpy( &g_sendhead, pChatMessage, sizeof(g_sendhead));
- g_nLeng=nMessageLen;
- if(nMessageLen<=sizeof(DWORD))
- {
- memcpy(&g_ncount2, pChatMessage->byFileContent, sizeof(DWORD));
- }
- g_bReturned2=1;
- }
|