AutoRun3Dlg.cpp 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214
  1. // AutoRun3Dlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "AutoRun3.h"
  5. #include "AutoRun3Dlg.h"
  6. #include "AutoRun3Dlg2.h"
  7. #include <afxsock.h>//<Winsock2.h>
  8. #include "ConnectDlg.h"
  9. #include "SendDataDlg.h"
  10. #include "AddContact.h"
  11. #include "SendReg.h"
  12. #include <Mmsystem.h>
  13. #include <tlhelp32.h>
  14. #include <afxinet.h>
  15. #include <afxext.h>
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. #pragma comment(lib, "Winmm.lib")
  22. #define IPC_CUSTOM_MSG2 _T("{a4Fa76E2-w78F-2aD5-q98A-Y0B0D078u2}")
  23. UINT g_wmClose = RegisterWindowMessage(IPC_CUSTOM_MSG2);
  24. CString g_mainpath;
  25. CString g_mainpath2;
  26. CString g_mainpath3;
  27. BOOL g_bAutoRun=0;
  28. #define WM_ICON_NOTIFY WM_USER+12
  29. DWORD g_nSendCode=0; //insert
  30. /////////////////////////////////////////////////////////////////////////////
  31. DWORD g_ncount2=0;
  32. HWND g_hSendWnd;
  33. extern HWND g_hConnectWnd;
  34. extern void DataToArray(CArray<CStringArray, CStringArray>*List1array);
  35. extern void DataToArray(CArray<CStringArray, CStringArray>*List1array, CArray<CStringArray, CStringArray>*List2array);
  36. #define DISCONNECT_TIMER (WM_USER + 101)
  37. #define LOGINFAILED_TIMER (WM_USER + 102)
  38. extern void MyGetIPByName(CString &name);
  39. BOOL g_bReturned=0;
  40. BOOL g_bReturned2=0;
  41. DWORD FindAppProcessID(CString path)
  42. {
  43. try
  44. {
  45. HANDLE handle=::CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
  46. PROCESSENTRY32 Info;
  47. Info.dwSize = sizeof(PROCESSENTRY32);
  48. path.MakeLower ();
  49. if(::Process32First(handle,&Info))
  50. {
  51. do
  52. {
  53. CString ss=Info.szExeFile;
  54. ss.MakeLower ();
  55. if(ss.Find (path)!=-1 || (!ss.CompareNoCase(path)) )
  56. {
  57. ::CloseHandle(handle);
  58. return Info.th32ProcessID;
  59. }
  60. }
  61. while(::Process32Next(handle,&Info));
  62. ::CloseHandle(handle);
  63. }
  64. return -1;
  65. }
  66. catch(...)
  67. {
  68. }
  69. }
  70. void WriteLogin(CString str)
  71. {
  72. try
  73. {
  74. DWORD ticks=::GetTickCount ();
  75. CString path=g_mainpath2+"\\autorun2.txt";
  76. {
  77. CFile fp;
  78. if(fp.Open (path, CFile::modeRead))
  79. {
  80. if(fp.GetLength ()/(1024*1024)>1)
  81. {
  82. fp.Close ();
  83. ::DeleteFile (path);
  84. }
  85. else
  86. fp.Close ();
  87. }
  88. }
  89. CStdioFile fp;
  90. if(::PathFileExists (path))
  91. {
  92. fp.Open (path, CFile::modeWrite);
  93. fp.SeekToEnd ();
  94. }
  95. else
  96. fp.Open (path, CFile::modeCreate|CFile::modeWrite);
  97. CString temp;
  98. temp.Format (" %dss ", ::GetTickCount ()-ticks);
  99. fp.WriteString (CTime::GetCurrentTime ().Format ("%Y-%m-%d %H:%M:%S")+temp+str+"\r\n" );
  100. fp.Close ();
  101. }
  102. catch(...)
  103. {
  104. }
  105. }
  106. void MyExitWindows()
  107. {
  108. try
  109. {
  110. UINT t=EWX_REBOOT|EWX_FORCE;
  111. OSVERSIONINFO osv; //定义一个操作系统信息的结构体
  112. osv.dwOSVersionInfoSize=sizeof OSVERSIONINFO;
  113. GetVersionEx(&osv); //查询当前操作系统
  114. if(osv.dwPlatformId==VER_PLATFORM_WIN32_NT) //判断是否是2000/NT
  115. {
  116. //下面为向操作系统获取权限操作
  117. HANDLE hProcess,hToken;
  118. TOKEN_PRIVILEGES Privileges;
  119. LUID luid;
  120. hProcess=GetCurrentProcess();
  121. //下面为打开当前进程对话
  122. OpenProcessToken(hProcess,TOKEN_ADJUST_PRIVILEGES,&hToken);
  123. Privileges.PrivilegeCount=1;
  124. LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&luid);
  125. Privileges.Privileges[0].Luid=luid;
  126. Privileges.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
  127. AdjustTokenPrivileges(hToken,FALSE,&Privileges,NULL,NULL,NULL);
  128. ExitWindowsEx(t,0);
  129. }
  130. else
  131. {
  132. ExitWindowsEx(t,0);//调用ExitWindowsEx关闭机器。
  133. PostQuitMessage(0);
  134. }
  135. }
  136. catch(...)
  137. {
  138. }
  139. }
  140. /////////////////////////////////////////////////////////////////////////////
  141. static void HandleClientNetEvent(IN SOCKET hSocket, IN ETransportEvent eEvent,
  142. IN void *pDataBuf, IN unsigned long nDataLen,
  143. IN int nError, IN void *pContext)
  144. {
  145. if( nError != TRANSPORT_OK ) return;
  146. CAutoRun3Dlg *pDlg = (CAutoRun3Dlg *)pContext;
  147. if( NULL == pDlg ) return;
  148. pDlg->ProcessNetEvent(eEvent, pDataBuf, nDataLen);
  149. }
  150. CAutoRun3Dlg::CAutoRun3Dlg(CWnd* pParent /*=NULL*/)
  151. : CDialog(CAutoRun3Dlg::IDD, pParent)
  152. {
  153. //{{AFX_DATA_INIT(CAutoRun3Dlg)
  154. m_strSendSms = _T("");
  155. m_strLoginID = _T("");
  156. m_strLoginPwd = _T("");
  157. m_strRecvMobi = _T("");
  158. m_strNewPwd = _T("");
  159. m_mobicount = 0;
  160. m_check1 = FALSE;
  161. m_count = 0;
  162. //}}AFX_DATA_INIT
  163. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  164. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  165. m_nMobile=0;
  166. m_nPhone=0;
  167. CString version = _T ("Version 1.0");
  168. g_bAutoRun=AfxGetApp()->GetProfileInt (version, "brun", 0);
  169. }
  170. void CAutoRun3Dlg::DoDataExchange(CDataExchange* pDX)
  171. {
  172. CDialog::DoDataExchange(pDX);
  173. //{{AFX_DATA_MAP(CAutoRun3Dlg)
  174. DDX_Control(pDX, IDC_LIST2, m_List1);
  175. DDX_Control(pDX, IDC_BTN_SEND, m_btnSend);
  176. DDX_Control(pDX, IDC_LST_SMS, m_listCtrl);
  177. DDX_Text(pDX, IDC_EDT_SMS, m_strSendSms);
  178. DDV_MaxChars(pDX, m_strSendSms, 2000);
  179. DDX_Text(pDX, IDC_EDT_LOGIN_ID, m_strLoginID);
  180. DDV_MaxChars(pDX, m_strLoginID, 11);
  181. DDX_Text(pDX, IDC_EDT_LOGIN_PWD, m_strLoginPwd);
  182. DDX_Text(pDX, IDC_EDT_RECV_MOBI, m_strRecvMobi);
  183. DDX_Text(pDX, IDC_EDT_NEW_PWD, m_strNewPwd);
  184. DDX_Text(pDX, IDC_EDT_NUM, m_mobicount);
  185. DDX_Check(pDX, IDC_CHECK1, m_check1);
  186. //}}AFX_DATA_MAP
  187. }
  188. BEGIN_MESSAGE_MAP(CAutoRun3Dlg, CDialog)
  189. //{{AFX_MSG_MAP(CAutoRun3Dlg)
  190. ON_WM_PAINT()
  191. ON_WM_QUERYDRAGICON()
  192. ON_WM_DESTROY()
  193. ON_BN_CLICKED(IDC_BTN_SEND, OnBtnSend)
  194. ON_BN_CLICKED(IDC_BTN_QUERY, OnBtnQuery)
  195. ON_BN_CLICKED(IDC_BTN_Query2, OnBTNQuery2)
  196. ON_BN_CLICKED(IDC_BTN_CHANGE_PWD, OnBtnChangePwd)
  197. ON_BN_CLICKED(IDC_BTN_GET_STATUS, OnBtnGetStatus)
  198. ON_WM_TIMER()
  199. ON_BN_CLICKED(IDC_BUTadd, OnBUTadd)
  200. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  201. ON_LBN_SELCHANGE(IDC_LIST2, OnSelchangeList2)
  202. ON_EN_CHANGE(IDC_EDT_SMS, OnChangeEdtSms)
  203. ON_EN_CHANGE(IDC_EDT_RECV_MOBI, OnChangeEdtRecvMobi)
  204. ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
  205. ON_BN_CLICKED(IDC_BTN_REG, OnBtnReg)
  206. ON_COMMAND(IDM_CLOSE, OnClose)
  207. ON_COMMAND(IDM_AUTORUN, OnAutorun)
  208. //}}AFX_MSG_MAP
  209. ON_MESSAGE(WM_ICON_NOTIFY, OnTrayNotification)
  210. ON_REGISTERED_MESSAGE(g_wmClose, OnAbortClose)
  211. END_MESSAGE_MAP()
  212. /////////////////////////////////////////////////////////////////////////////
  213. LRESULT CAutoRun3Dlg::OnTrayNotification(WPARAM wParam,LPARAM lParam)
  214. {
  215. return m_TrayIcon.OnTrayNotification(wParam,lParam);
  216. }
  217. LRESULT CAutoRun3Dlg::OnAbortClose(WPARAM wParam, LPARAM lParam)
  218. {
  219. return 1;
  220. }
  221. BOOL CAutoRun3Dlg::OnInitDialog()
  222. {
  223. SetWindowPos(&wndNoTopMost,0,0,0,0,SWP_HIDEWINDOW);
  224. ModifyStyleEx(WS_EX_APPWINDOW,WS_EX_TOOLWINDOW);
  225. CDialog::OnInitDialog();
  226. // Set the icon for this dialog. The framework does this automatically
  227. // when the application's main window is not a dialog
  228. SetIcon(m_hIcon, TRUE); // Set big icon
  229. SetIcon(m_hIcon, FALSE); // Set small icon
  230. g_pMainWnd=this;
  231. char path[MAX_PATH];
  232. ::GetModuleFileName (NULL, path, MAX_PATH);
  233. g_mainpath=path;
  234. g_mainpath=g_mainpath.Left (g_mainpath.ReverseFind ('\\'));
  235. g_mainpath3=g_mainpath2=g_mainpath;
  236. ShellExecute(NULL, _T("open"), g_mainpath2+"\\AutoRun2.exe", "0", NULL, SW_SHOWNORMAL);
  237. SetTimer(1, 2*1000, NULL);
  238. /////////////////////////////////
  239. // TODO: Add extra initialization here
  240. return TRUE; // return TRUE unless you set the focus to a control
  241. }
  242. // If you add a minimize button to your dialog, you will need the code below
  243. // to draw the icon. For MFC applications using the document/view model,
  244. // this is automatically done for you by the framework.
  245. void CAutoRun3Dlg::OnPaint()
  246. {
  247. if (IsIconic())
  248. {
  249. CPaintDC dc(this); // device context for painting
  250. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  251. // Center icon in client rectangle
  252. int cxIcon = GetSystemMetrics(SM_CXICON);
  253. int cyIcon = GetSystemMetrics(SM_CYICON);
  254. CRect rect;
  255. GetClientRect(&rect);
  256. int x = (rect.Width() - cxIcon + 1) / 2;
  257. int y = (rect.Height() - cyIcon + 1) / 2;
  258. // Draw the icon
  259. dc.DrawIcon(x, y, m_hIcon);
  260. }
  261. else
  262. {
  263. CDialog::OnPaint();
  264. }
  265. }
  266. // The system calls this to obtain the cursor to display while the user drags
  267. // the minimized window.
  268. HCURSOR CAutoRun3Dlg::OnQueryDragIcon()
  269. {
  270. return (HCURSOR) m_hIcon;
  271. }
  272. DWORD CAutoRun3Dlg::GetConnectionID()
  273. {
  274. return m_dwConnectionID;
  275. }
  276. void CAutoRun3Dlg::SetConnectionID(DWORD dwConnection)
  277. {
  278. m_dwConnectionID = dwConnection;
  279. }
  280. void CAutoRun3Dlg::ProcessChatMessageRequest2(CString sql)
  281. {
  282. const char *szDataBuf = sql.GetBuffer(0);
  283. sql.ReleaseBuffer();
  284. ProcessChatMessageRequest((void*)szDataBuf, strlen(szDataBuf) + 1);
  285. }
  286. void CAutoRun3Dlg::ProcessChatMessageRequest2(BYTE *pData, int length)
  287. {
  288. ProcessChatMessageRequest((void*)pData, length);
  289. }
  290. BOOL CAutoRun3Dlg::ProcessChatMessageRequest(void *szDataBuf, int nDataLen)
  291. {
  292. g_bReturned=0;
  293. DWORD dwFromUserID = GetConnectionID();
  294. WORD wMessageId = MSG_CHATMESSAGE_REQ;
  295. DWORD dwDataLen = sizeof(TCHAT_MESSAGE_STRU) + nDataLen;
  296. BYTE *pSendData = new BYTE[dwDataLen];
  297. TCHAT_MESSAGE_STRU *pChatMessage=(TCHAT_MESSAGE_STRU*)pSendData;
  298. memset(pChatMessage, 0x00, dwDataLen);
  299. g_sendhead.length[98]=987123768;
  300. memcpy(pSendData, &g_sendhead, sizeof(g_sendhead));
  301. pChatMessage->tCommonMsg.dwConnectionID = GetConnectionID();
  302. pChatMessage->tCommonMsg.wMessageId = wMessageId;
  303. pChatMessage->dwFromUserID = dwFromUserID;
  304. pChatMessage->dwToUserID = g_nSendCode;
  305. pChatMessage->wMessageLen = nDataLen;
  306. memcpy(pChatMessage->byFileContent, szDataBuf, nDataLen);
  307. TMessageHeader tHeader = {0};
  308. tHeader.wMessageId = wMessageId;
  309. tHeader.dwDataLen = dwDataLen;
  310. BOOL bRet=0;
  311. unsigned long ulSendLen = m_tClientTunnel.net_Send(&tHeader, (void *)pChatMessage, dwDataLen);
  312. if( ulSendLen != SOCKET_ERROR )
  313. {
  314. bRet=1;
  315. }
  316. delete [] pSendData;
  317. return bRet;
  318. }
  319. BOOL CAutoRun3Dlg::OnConnect()
  320. {
  321. g_server="lijiafz.vicp.net" ;
  322. MyGetIPByName(g_server);
  323. if(g_server.IsEmpty ())return OnConnect2();
  324. CString strServerAddress = g_server;
  325. char *szServerAddress = strServerAddress.GetBuffer(0);
  326. strServerAddress.ReleaseBuffer();
  327. /*for Client, IP and Port can be 0,
  328. and for Server, IP is LocalIP, and Port is Listening Port*/
  329. int nResult = m_tClientTunnel.net_OpenSocket(Transport_Client,
  330. 0,
  331. HandleClientNetEvent,
  332. this);
  333. if( TRANSPORT_OK != nResult )
  334. {
  335. return 0;
  336. }
  337. DWORD dwRemoteIPValue = inet_addr(szServerAddress);
  338. WORD wPort = 8379;
  339. nResult = m_tClientTunnel.net_Connect(dwRemoteIPValue, wPort);
  340. if( TRANSPORT_OK != nResult )
  341. {
  342. m_tClientTunnel.net_CloseSocket();
  343. return OnConnect2();
  344. }
  345. return ProcessLoginRequest();
  346. }
  347. BOOL CAutoRun3Dlg::OnConnect2()
  348. {
  349. CString server="http://www.lyfz.net/download/ip.txt";
  350. char buf[MAX_PATH];
  351. ::GetTempPath(sizeof(buf),buf);
  352. CString m_strTempDir=buf;
  353. DWORD m_dwHttpRequestFlags=HSR_DOWNLOAD | INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_NO_AUTO_REDIRECT;
  354. INTERNET_PORT m_dwPort;
  355. DWORD dwType;
  356. CInternetSession m_cis;
  357. CHttpConnection *m_pHttp;
  358. CString m_strServer;
  359. CString m_strIniPath;
  360. AfxParseURL(server,dwType,m_strServer,m_strIniPath,m_dwPort);
  361. if(dwType!=AFX_INET_SERVICE_HTTP)
  362. {
  363. return OnConnect3();
  364. }
  365. m_cis.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,5);
  366. m_pHttp=m_cis.GetHttpConnection(m_strServer,m_dwPort);
  367. try
  368. {
  369. m_pHttp=m_cis.GetHttpConnection(m_strServer,m_dwPort);
  370. }
  371. catch(CInternetException* pEx)
  372. {
  373. return OnConnect3();
  374. }
  375. CHttpFile *pFile = m_pHttp->OpenRequest(CHttpConnection::HTTP_VERB_GET,
  376. m_strIniPath, NULL, 1, NULL, NULL, m_dwHttpRequestFlags);
  377. try
  378. {
  379. pFile->SendRequest();
  380. }
  381. catch(CInternetException* pEx)
  382. {
  383. pFile->Close();
  384. return OnConnect3();
  385. }
  386. if(pFile)
  387. {
  388. CStdioFile csf;
  389. csf.Open(m_strTempDir+"\\ip.txt",CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
  390. char buf[2048];
  391. int n;
  392. while((n=pFile->Read(buf,2048))>0)
  393. csf.Write(buf,n);
  394. csf.Close();
  395. pFile->Close();
  396. }
  397. CStdioFile fp;
  398. fp.Open (m_strTempDir+"\\ip.txt", CFile::modeRead);
  399. fp.ReadString (g_server);
  400. fp.Close ();
  401. CString strServerAddress = g_server;
  402. char *szServerAddress = strServerAddress.GetBuffer(0);
  403. strServerAddress.ReleaseBuffer();
  404. /*for Client, IP and Port can be 0,
  405. and for Server, IP is LocalIP, and Port is Listening Port*/
  406. int nResult = m_tClientTunnel.net_OpenSocket(Transport_Client,
  407. 0,
  408. HandleClientNetEvent,
  409. this);
  410. if( TRANSPORT_OK != nResult )
  411. {
  412. return 0;
  413. }
  414. DWORD dwRemoteIPValue = inet_addr(szServerAddress);
  415. WORD wPort = 8379;
  416. nResult = m_tClientTunnel.net_Connect(dwRemoteIPValue, wPort);
  417. if( TRANSPORT_OK != nResult )
  418. {
  419. m_tClientTunnel.net_CloseSocket();
  420. return OnConnect3();
  421. }
  422. return ProcessLoginRequest();
  423. }
  424. BOOL CAutoRun3Dlg::OnConnect3()
  425. {
  426. CString server="http://photo.bjlyfz.com/download/ip.txt";
  427. char buf[MAX_PATH];
  428. ::GetTempPath(sizeof(buf),buf);
  429. CString m_strTempDir=buf;
  430. DWORD m_dwHttpRequestFlags=HSR_DOWNLOAD | INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_NO_AUTO_REDIRECT;
  431. INTERNET_PORT m_dwPort;
  432. DWORD dwType;
  433. CInternetSession m_cis;
  434. CHttpConnection *m_pHttp;
  435. CString m_strServer;
  436. CString m_strIniPath;
  437. AfxParseURL(server,dwType,m_strServer,m_strIniPath,m_dwPort);
  438. if(dwType!=AFX_INET_SERVICE_HTTP)
  439. {
  440. return FALSE;
  441. }
  442. m_cis.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,5);
  443. m_pHttp=m_cis.GetHttpConnection(m_strServer,m_dwPort);
  444. try
  445. {
  446. m_pHttp=m_cis.GetHttpConnection(m_strServer,m_dwPort);
  447. }
  448. catch(CInternetException* pEx)
  449. {
  450. return false;
  451. }
  452. CHttpFile *pFile = m_pHttp->OpenRequest(CHttpConnection::HTTP_VERB_GET,
  453. m_strIniPath, NULL, 1, NULL, NULL, m_dwHttpRequestFlags);
  454. try
  455. {
  456. pFile->SendRequest();
  457. }
  458. catch(CInternetException* pEx)
  459. {
  460. pFile->Close();
  461. return false;
  462. }
  463. if(pFile)
  464. {
  465. CStdioFile csf;
  466. csf.Open(m_strTempDir+"\\ip.txt",CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
  467. char buf[2048];
  468. int n;
  469. while((n=pFile->Read(buf,2048))>0)
  470. csf.Write(buf,n);
  471. csf.Close();
  472. pFile->Close();
  473. }
  474. CStdioFile fp;
  475. fp.Open (m_strTempDir+"\\ip.txt", CFile::modeRead);
  476. fp.ReadString (g_server);
  477. fp.Close ();
  478. CString strServerAddress = g_server;
  479. char *szServerAddress = strServerAddress.GetBuffer(0);
  480. strServerAddress.ReleaseBuffer();
  481. /*for Client, IP and Port can be 0,
  482. and for Server, IP is LocalIP, and Port is Listening Port*/
  483. int nResult = m_tClientTunnel.net_OpenSocket(Transport_Client,
  484. 0,
  485. HandleClientNetEvent,
  486. this);
  487. if( TRANSPORT_OK != nResult )
  488. {
  489. return 0;
  490. }
  491. DWORD dwRemoteIPValue = inet_addr(szServerAddress);
  492. WORD wPort = 8379;
  493. nResult = m_tClientTunnel.net_Connect(dwRemoteIPValue, wPort);
  494. if( TRANSPORT_OK != nResult )
  495. {
  496. m_tClientTunnel.net_CloseSocket();
  497. return 0;
  498. }
  499. return ProcessLoginRequest();
  500. }
  501. void CAutoRun3Dlg::ProcessNetEvent(int nEventType, void *pRecvMsg, DWORD dwDataLen)
  502. {
  503. if( Transport_ReadEv == nEventType )
  504. {
  505. if( NULL == pRecvMsg ) return;
  506. TMessageHeader* pHeader = (TMessageHeader *)pRecvMsg;
  507. char *pDataBuf = (char *)pRecvMsg + MESSAGE_HEADER_LEN;
  508. WORD dwMessageID = pHeader->wMessageId;
  509. switch(dwMessageID)
  510. {
  511. case MSG_LOGIN_RESP:
  512. {
  513. LOGIN_RESULT_STRU tLoginResult = {0};
  514. memcpy(&tLoginResult, pDataBuf, sizeof(LOGIN_RESULT_STRU));
  515. ProcessLoginResponse(&tLoginResult);
  516. break;
  517. }
  518. case MSG_USERINFO_RESP:
  519. {
  520. TUSERLIST_INFO_STRU tUserListInfo = {0};
  521. memcpy(&tUserListInfo, pDataBuf, sizeof(TUSERLIST_INFO_STRU));
  522. // ProcessUserListInfoResponse(&tUserListInfo);
  523. break;
  524. }
  525. case MSG_LOGOUT_RESP:
  526. {
  527. TUSERLIST_INFO_STRU tUserListInfo = {0};
  528. memcpy(&tUserListInfo, pDataBuf, sizeof(TUSERLIST_INFO_STRU));
  529. // ProcessLogoutResponse(&tUserListInfo);
  530. break;
  531. }
  532. case MSG_CHATMESSAGE_RESP:
  533. {
  534. TCHAT_MESSAGE_STRU *pChatMessage = (TCHAT_MESSAGE_STRU *)pDataBuf;
  535. ProcessChatMessageResponse((void *)pChatMessage);
  536. break;
  537. }
  538. default:
  539. {
  540. break;
  541. }
  542. }
  543. }
  544. else if( Transport_CloseEv == nEventType )
  545. {
  546. SetTimer(DISCONNECT_TIMER, 0, NULL);
  547. }
  548. ///////
  549. }
  550. void CAutoRun3Dlg::OnDisconnect()
  551. {
  552. m_tClientTunnel.net_CloseSocket();
  553. SetConnectionID(INVALID_SOCKET);
  554. }
  555. void CAutoRun3Dlg::ProcessLoginResponse(void *pLoginResult)
  556. {
  557. if( NULL == pLoginResult ) return;
  558. LOGIN_RESULT_STRU *ptLoginResult = (LOGIN_RESULT_STRU *)pLoginResult;
  559. DWORD dwConnectionID = ptLoginResult->tCommonMsg.dwConnectionID;
  560. SetConnectionID(dwConnectionID);
  561. BYTE byResult = ptLoginResult->byResult;
  562. if(LOGIN_RESULT_SUC == byResult)
  563. {
  564. }
  565. else
  566. {
  567. SetTimer(LOGINFAILED_TIMER, 0, NULL);
  568. }
  569. CString strCommentInfo("");
  570. strCommentInfo.Format("%s. 用户代号: %ld",
  571. ((LOGIN_RESULT_SUC == byResult) ? "登录成功" :
  572. (LOGIN_RESULT_MULTI == byResult) ? "重复登录" :
  573. (LOGIN_RESULT_NAMERROR == byResult) ? "名字不存在" :
  574. (LOGIN_RESULT_PWERROR == byResult) ? "密码错误" : "登录失败"),
  575. dwConnectionID);
  576. // MessageBox((CString)strCommentInfo);
  577. }
  578. CString newGUID()
  579. {
  580. CString str;
  581. GUID guid;
  582. CoInitialize(NULL);
  583. if (S_OK == ::CoCreateGuid(&guid))
  584. {
  585. str.Format (
  586. "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
  587. guid.Data1,
  588. guid.Data2,
  589. guid.Data3,
  590. guid.Data4[0], guid.Data4[1],
  591. guid.Data4[2], guid.Data4[3],
  592. guid.Data4[4], guid.Data4[5],
  593. guid.Data4[6], guid.Data4[7]);
  594. }
  595. CoUninitialize();
  596. return str.Left (28);
  597. }
  598. BOOL CAutoRun3Dlg::ProcessLoginRequest()
  599. {
  600. WORD wMessageId = MSG_LOGIN_REQ;
  601. TLOGIN_STRU tLogonInfo = {0};
  602. tLogonInfo.tCommonMsg.dwConnectionID = GetConnectionID();
  603. tLogonInfo.tCommonMsg.wMessageId = wMessageId;
  604. CString strUserName = newGUID();
  605. strUserName.TrimLeft();
  606. strUserName.TrimRight();
  607. strcpy(tLogonInfo.tUserInfo.szUserName, strUserName);
  608. DWORD dwDataLen = sizeof(TLOGIN_STRU);
  609. TMessageHeader tHeader = {0};
  610. tHeader.wMessageId = wMessageId;
  611. tHeader.dwDataLen = dwDataLen;
  612. unsigned long ulSendLen = m_tClientTunnel.net_Send(&tHeader, (void *)&tLogonInfo, dwDataLen);
  613. if( ulSendLen == SOCKET_ERROR )
  614. {
  615. return 0;
  616. }
  617. return 1;
  618. }
  619. //---------------------------------------------------------------------------
  620. void CAutoRun3Dlg::OnDestroy()
  621. {
  622. CDialog::OnDestroy();
  623. OnDisconnect();
  624. Transport_UnInit();
  625. m_TrayIcon.RemoveIcon();
  626. }
  627. int GetAppProcessCount(CString path)
  628. {
  629. int count=0;
  630. HANDLE handle=::CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
  631. PROCESSENTRY32 Info;
  632. Info.dwSize = sizeof(PROCESSENTRY32);
  633. path.MakeLower ();
  634. if(::Process32First(handle,&Info))
  635. {
  636. do
  637. {
  638. CString ss=Info.szExeFile;
  639. ss.MakeLower ();
  640. if(ss.Find (path)!=-1 || (!ss.CompareNoCase(path)) )
  641. {
  642. count++;
  643. }
  644. }
  645. while(::Process32Next(handle,&Info));
  646. ::CloseHandle(handle);
  647. }
  648. return count;
  649. }
  650. void CAutoRun3Dlg::OnBUTadd()
  651. {
  652. // TODO: Add your control notification handler code here
  653. AddContact dlg;
  654. if(dlg.DoModal ()!=IDOK)return;
  655. CString str;
  656. int pos;
  657. for(int i=0; i<m_List1.GetCount (); i++)
  658. {
  659. m_List1.GetText (i, str);
  660. pos=str.Find ("\r\n");
  661. if(dlg.m_phone==str.Right (str.GetLength ()-pos-2))
  662. {
  663. AfxMessageBox("已有此电话的记录!");
  664. return;
  665. }
  666. }
  667. CString sql;
  668. sql= "insert into contact([name],[phone]) values(\
  669. '"+dlg.m_name+"',\
  670. '"+dlg.m_phone+"')";
  671. g_db.ExecuteSQL (sql);
  672. if(m_List1.GetCount()%2)
  673. m_List1.AddEntry( dlg.m_name+"\r\n"+dlg.m_phone , RGB(240,247,255), m_List1.GetCount());
  674. else
  675. m_List1.AddEntry( dlg.m_name+"\r\n"+dlg.m_phone , RGB(255,248,240), m_List1.GetCount());
  676. }
  677. void CAutoRun3Dlg::OnBUTdel()
  678. {
  679. // TODO: Add your control notification handler code here
  680. int listpos=m_List1.GetCurSel ();
  681. if(listpos==-1)
  682. {
  683. AfxMessageBox("请先选中您要删除的联系人!");
  684. return;
  685. }
  686. if(AfxMessageBox("警告:删除后将不可恢复, 继续吗?", MB_YESNO|MB_ICONSTOP)!=IDYES)return;
  687. CString str;
  688. m_List1.GetText (listpos, str);
  689. int pos=str.Find ("\r\n");
  690. CString name=str.Left (pos);
  691. CString phone=str.Right (str.GetLength ()-pos-2);
  692. CString sql;
  693. sql= "delete from contact where [name]='"+name+"' and [phone]='"+phone+"'";
  694. g_db.ExecuteSQL (sql);
  695. m_List1.DeleteString(listpos);
  696. }
  697. void CAutoRun3Dlg::OnSelchangeList2()
  698. {
  699. // TODO: Add your control notification handler code here
  700. UpdateData();
  701. int count= m_List1.GetSelCount() ;
  702. if(count==0)return;
  703. int *pIndex=new int[count];
  704. m_List1.GetSelItems(count, pIndex);
  705. m_strRecvMobi = _T("");
  706. m_mobicount = 0;
  707. CString str;
  708. int pos;
  709. m_nMobile=0;
  710. m_nPhone=0;
  711. for(int i=0; i<count; i++)
  712. {
  713. m_List1.GetText (pIndex[i], str);
  714. pos=str.Find ("\r\n");
  715. if(CheckPhoneType(str.Right (str.GetLength ()-pos-2))==0)
  716. m_nMobile++;
  717. else if(CheckPhoneType(str.Right (str.GetLength ()-pos-2))==1)
  718. m_nPhone++;
  719. else
  720. {
  721. AfxMessageBox("号码"+str.Right (str.GetLength ()-pos-2)+"不是正确的电话号码!", MB_ICONSTOP);
  722. continue;
  723. }
  724. m_strRecvMobi+=str.Right (str.GetLength ()-pos-2);
  725. m_strRecvMobi+=",";
  726. m_mobicount++;
  727. }
  728. m_strRecvMobi.TrimRight (",");
  729. UpdateData(false);
  730. delete []pIndex;
  731. OnChangeEdtSms();
  732. }
  733. int CAutoRun3Dlg::CheckPhoneType(CString phoneno)
  734. {
  735. if(phoneno.IsEmpty())return -1;
  736. for(int i=0; i<phoneno.GetLength (); i++)
  737. {
  738. if(phoneno.GetAt (i)<'0'||phoneno.GetAt (i)>'9')return -1;
  739. }
  740. if(phoneno.GetAt (0)=='1')
  741. {
  742. if(phoneno.GetLength ()!=11)
  743. return -1;
  744. int mobile[]={139,138,137,136,135,134,159,158,152,151,150,157,188,187,144};
  745. int unicom[]={130,131,132,155,156,186,185};
  746. int telecom[]={133,153,189,180};
  747. BOOL bFind=0;
  748. for(i=0; i<sizeof(mobile)/sizeof(int); i++)
  749. {
  750. if(mobile[i]==atoi(phoneno.Left (3)))
  751. {
  752. bFind=1;
  753. break;
  754. }
  755. }
  756. for(i=0; i<sizeof(unicom)/sizeof(int); i++)
  757. {
  758. if(unicom[i]==atoi(phoneno.Left (3)))
  759. {
  760. bFind=1;
  761. break;
  762. }
  763. }
  764. for(i=0; i<sizeof(telecom)/sizeof(int); i++)
  765. {
  766. if(telecom[i]==atoi(phoneno.Left (3)))
  767. {
  768. bFind=1;
  769. break;
  770. }
  771. }
  772. if(!bFind)
  773. return -1;
  774. else
  775. {
  776. // m_nMobile++;
  777. return 0;
  778. }
  779. }
  780. return -1;
  781. }
  782. /*
  783. 移动:
  784. 139,138,137,136,135,134,159,158,152,151,150,157,188,187,144
  785. 联通:
  786. 130,131,132,155,156,186,185
  787. 电信:
  788. 133,153,189,180
  789. */
  790. void CAutoRun3Dlg::OnChangeEdtRecvMobi()
  791. {
  792. // TODO: If this is a RICHEDIT control, the control will not
  793. // send this notification unless you override the CDialog::OnInitDialog()
  794. // function and call CRichEditCtrl().SetEventMask()
  795. // with the ENM_CHANGE flag ORed into the mask.
  796. // TODO: Add your control notification handler code here
  797. }
  798. void CAutoRun3Dlg::OnChangeEdtSms()
  799. {
  800. // TODO: If this is a RICHEDIT control, the control will not
  801. // send this notification unless you override the CDialog::OnInitDialog()
  802. // function and call CRichEditCtrl().SetEventMask()
  803. // with the ENM_CHANGE flag ORed into the mask.
  804. UpdateData();
  805. m_strSendSms.Replace ("'", "'");
  806. m_strSendSms.Replace ("(", "(");
  807. m_strSendSms.Replace (")", ")");
  808. SetDlgItemText(IDC_EDT_SMS, m_strSendSms);
  809. ((CEdit*)GetDlgItem(IDC_EDT_SMS))->SetSel(m_strSendSms.GetLength (),m_strSendSms.GetLength ());
  810. CString str;
  811. int count=0;
  812. int leng=GetLengthEx(m_strSendSms);
  813. if(m_nMobile)
  814. {
  815. count+=m_nMobile*(leng/70);
  816. if(leng%70)
  817. count+=m_nMobile;
  818. }
  819. if(m_nPhone)
  820. {
  821. count+=m_nPhone*(leng/56);
  822. if(leng%56)
  823. count+=m_nPhone;
  824. }
  825. m_count=count;
  826. str.Format ("短信内容(手机70字/条,小灵通56字/条)(现%d字,共%d条短信)", leng,count);
  827. GetDlgItem(IDC_STATIC1)->SetWindowText(str);
  828. // TODO: Add your control notification handler code here
  829. }
  830. int CAutoRun3Dlg::GetLengthEx(CString str)
  831. {
  832. int leng=0;
  833. TBYTE ucHigh, ucLow;
  834. for (int i=0; i<str.GetLength(); i++)
  835. {
  836. if ( (TBYTE)str[i] < 0x80 )
  837. {
  838. leng++;
  839. continue;
  840. }
  841. ucHigh = (TBYTE)str[i];
  842. ucLow = (TBYTE)str[i+1];
  843. if ( ucHigh < 0xa1 || ucLow < 0xa1)
  844. {
  845. leng++;
  846. continue;
  847. }
  848. leng++;
  849. i++;
  850. }
  851. return leng;
  852. }
  853. //---------------------------------------------------------------------------
  854. void CAutoRun3Dlg::OnBtnSend()
  855. {
  856. }
  857. void CAutoRun3Dlg::OnCheck1()
  858. {
  859. // TODO: Add your control notification handler code here
  860. UpdateData();
  861. }
  862. //---------------------------------------------------------------------------
  863. void CAutoRun3Dlg::OnBtnQuery() //查询余额
  864. {
  865. }
  866. //---------------------------------------------------------------------------
  867. void CAutoRun3Dlg::OnBTNQuery2()//查询使用
  868. {
  869. }
  870. void CAutoRun3Dlg::OnBtnChangePwd()
  871. {
  872. }
  873. void CAutoRun3Dlg::OnBtnGetStatus()
  874. {
  875. }
  876. BOOL CAutoRun3Dlg::MyExecuteSQL(CDatabase *pdb, CString sql)
  877. {
  878. try
  879. {
  880. pdb->ExecuteSQL (sql);
  881. }
  882. catch(...)
  883. {
  884. return 0;
  885. }
  886. return 1;
  887. }
  888. BOOL CAutoRun3Dlg::CheckExist(CString content, CString phones)
  889. {
  890. CRecordset myset(&g_db);
  891. CString sql="select count(*) as cot from sendreg where [content]='"+content+"' and [phones]='"+phones+"'";
  892. myset.Open (CRecordset::forwardOnly, sql);
  893. if(!myset.IsEOF())
  894. {
  895. myset.GetFieldValue ("cot", sql);
  896. if(atoi(sql))
  897. return 1;
  898. else
  899. return 0;
  900. }
  901. else
  902. return 0;
  903. }
  904. void CAutoRun3Dlg::OnBtnReg()
  905. {
  906. // TODO: Add your control notification handler code here
  907. UpdateData();
  908. SendReg dlg;
  909. dlg.m_strLoginID=m_strLoginID;
  910. dlg.m_strLoginPwd=m_strLoginPwd;
  911. dlg.DoModal ();
  912. }
  913. void CAutoRun3Dlg::OnClose()
  914. {
  915. // TODO: Add your command handler code here
  916. TerminateThread();
  917. CDialog::OnCancel ();
  918. }
  919. BOOL CAutoRun3Dlg::TerminateThread()
  920. {
  921. try
  922. {
  923. if ( !m_bRunning )
  924. return TRUE;
  925. m_bTerminate=true;
  926. for( ; ; )
  927. {
  928. if ( ::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0 )
  929. break;
  930. MSG msg;
  931. while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
  932. {
  933. if (!AfxGetApp()->PumpMessage())
  934. break;
  935. }
  936. }
  937. ::CloseHandle(m_hThread);
  938. m_bRunning=false;
  939. return TRUE;
  940. }
  941. catch(...)
  942. {
  943. }
  944. }
  945. CArray<CStringArray, CStringArray>g_List1array;
  946. DWORD g_nLeng=0;
  947. BYTE *g_pData=NULL;
  948. CString g_str="";
  949. void CAutoRun3Dlg::ProcessChatMessageResponse(void *pResponse)
  950. {
  951. if( NULL == pResponse ) return;
  952. g_str="";
  953. TCHAT_MESSAGE_STRU *pChatMessage = (TCHAT_MESSAGE_STRU *)pResponse;
  954. int nMessageLen = pChatMessage->wMessageLen;
  955. DWORD dwToUserID = pChatMessage->dwToUserID;
  956. char *pStr=new char[nMessageLen+1];
  957. memset(pStr, 0, nMessageLen+1);
  958. memcpy(pStr, pChatMessage->byFileContent, nMessageLen);
  959. CString str=pStr;
  960. delete []pStr;
  961. if(str=="账户或密码错误!")
  962. {
  963. g_bSendOK=0;
  964. }
  965. else
  966. {
  967. if(dwToUserID==0 && str!="发送信息成功!")
  968. g_bSendOK=0;
  969. else
  970. g_bSendOK=1;
  971. }
  972. g_str=str;
  973. g_bReturned=1;
  974. }
  975. void CAutoRun3Dlg::OnAutorun()
  976. {
  977. // TODO: Add your command handler code here
  978. g_bAutoRun=!g_bAutoRun;
  979. CString version = _T ("Version 1.0");
  980. AfxGetApp()->WriteProfileInt (version, "brun", g_bAutoRun);
  981. TCHAR szKey[MAX_PATH];
  982. HKEY hKey=0;
  983. DWORD disp=0;
  984. lstrcpy(szKey,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
  985. if(g_bAutoRun)
  986. {
  987. int lResult=RegCreateKeyEx(HKEY_LOCAL_MACHINE,szKey,0,NULL,REG_OPTION_VOLATILE, KEY_ALL_ACCESS,NULL,&hKey,&disp);
  988. if(lResult==ERROR_SUCCESS)
  989. {
  990. TCHAR szDir[MAX_PATH];
  991. ::GetModuleFileName (NULL, szDir, MAX_PATH);
  992. lResult=RegSetValueEx(hKey,"YLGLAutoRun3",0,REG_SZ,(const unsigned char*)szDir,lstrlen(szDir));
  993. RegCloseKey(hKey);
  994. }
  995. }
  996. else
  997. {
  998. int lResult=RegCreateKeyEx(HKEY_LOCAL_MACHINE,szKey,0,NULL,REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,NULL,&hKey,&disp);
  999. if(lResult==ERROR_SUCCESS)
  1000. {
  1001. RegDeleteValue(hKey,"YLGLAutoRun3");
  1002. RegDeleteKey (hKey,"YLGLAutoRun3");
  1003. RegCloseKey(hKey);
  1004. }
  1005. }
  1006. }
  1007. CString g_ip="";
  1008. void CAutoRun3Dlg::UpdateMyIP()
  1009. {
  1010. }
  1011. void CloseErrorWnd()
  1012. {
  1013. int i;
  1014. {
  1015. HWND hwnd=::FindWindow (NULL, "LYFZSendMsg.exe - 应用程序错误");
  1016. if(hwnd)
  1017. {
  1018. HWND child=::FindWindowEx(hwnd, 0, NULL, "确定");
  1019. CWnd *pWnd = CWnd::FromHandle( child );
  1020. ::SendMessage( hwnd, WM_COMMAND, pWnd->GetDlgCtrlID(), (LPARAM) child );
  1021. }
  1022. }
  1023. for(i=0; i<20; i++)
  1024. {
  1025. HWND hwnd=::FindWindow (NULL, "Socket Notification Sink: LYFZReceiveMsg.exe - 应用程序错误");
  1026. if(hwnd)
  1027. {
  1028. HWND child=::FindWindowEx(hwnd, 0, NULL, "确定");
  1029. CWnd *pWnd = CWnd::FromHandle( child );
  1030. ::SendMessage( hwnd, WM_COMMAND, pWnd->GetDlgCtrlID(), (LPARAM) child );
  1031. }
  1032. else
  1033. break;
  1034. }
  1035. for(i=0; i<20; i++)
  1036. {
  1037. HWND hwnd=::FindWindow (NULL, "Socket Notification Sink: LYFZIPReceive.exe - 应用程序错误");
  1038. if(hwnd)
  1039. {
  1040. HWND child=::FindWindowEx(hwnd, 0, NULL, "确定");
  1041. CWnd *pWnd = CWnd::FromHandle( child );
  1042. ::SendMessage( hwnd, WM_COMMAND, pWnd->GetDlgCtrlID(), (LPARAM) child );
  1043. }
  1044. else
  1045. break;
  1046. }
  1047. for(i=0; i<20; i++)
  1048. {
  1049. HWND hwnd=::FindWindow (NULL, "LYFZIPReceive.exe - 应用程序错误");
  1050. if(hwnd)
  1051. {
  1052. HWND child=::FindWindowEx(hwnd, 0, NULL, "确定");
  1053. CWnd *pWnd = CWnd::FromHandle( child );
  1054. ::SendMessage( hwnd, WM_COMMAND, pWnd->GetDlgCtrlID(), (LPARAM) child );
  1055. }
  1056. else
  1057. break;
  1058. }
  1059. for(i=0; i<20; i++)
  1060. {
  1061. HWND hwnd=::FindWindow (NULL, "LYFZReceiveMsg.exe - 应用程序错误");
  1062. if(hwnd)
  1063. {
  1064. HWND child=::FindWindowEx(hwnd, 0, NULL, "确定");
  1065. CWnd *pWnd = CWnd::FromHandle( child );
  1066. ::SendMessage( hwnd, WM_COMMAND, pWnd->GetDlgCtrlID(), (LPARAM) child );
  1067. }
  1068. else
  1069. break;
  1070. }
  1071. for(i=0; i<20; i++)
  1072. {
  1073. HWND hwnd=::FindWindow (NULL, "Microsoft Visual C++ Debug Library");
  1074. if(hwnd)
  1075. {
  1076. HWND child=::FindWindowEx(hwnd, 0, NULL, "终止(&A)");
  1077. CWnd *pWnd = CWnd::FromHandle( child );
  1078. ::SendMessage( hwnd, WM_COMMAND, pWnd->GetDlgCtrlID(), (LPARAM) child );
  1079. }
  1080. else
  1081. break;
  1082. }
  1083. }
  1084. void CAutoRun3Dlg::OnTimer(UINT nIDEvent)
  1085. {
  1086. // TODO: Add your message handler code here and/or call default
  1087. if( 1 == nIDEvent )
  1088. {
  1089. CloseErrorWnd();
  1090. }
  1091. }