123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- #include "stdafx.h"
- #include "lyfzSMSHandle.h"
- #include "lyfzSMSHandleDlg.h"
- #include "Global.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- HANDLE g_hMutex = NULL;
- BEGIN_MESSAGE_MAP(ClyfzSMSHandleApp, CWinAppEx)
- ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
- END_MESSAGE_MAP()
- ClyfzSMSHandleApp::ClyfzSMSHandleApp()
- {
-
-
- }
- ClyfzSMSHandleApp theApp;
- BOOL ClyfzSMSHandleApp::InitInstance()
- {
- g_hMutex = ::CreateMutex(NULL,FALSE,_T("lyfzSMSHandle"));
- if( GetLastError() == ERROR_ALREADY_EXISTS )
- {
- ::MessageBox(NULL,_T("短信处理程序已经打开!"),_T("温馨提示"),MB_ICONINFORMATION);
- return FALSE;
- }
-
-
-
- INITCOMMONCONTROLSEX InitCtrls;
- InitCtrls.dwSize = sizeof(InitCtrls);
-
-
- InitCtrls.dwICC = ICC_WIN95_CLASSES;
- InitCommonControlsEx(&InitCtrls);
- CWinAppEx::InitInstance();
- AfxEnableControlContainer();
-
- TCHAR szDrive[_MAX_DRIVE];
- TCHAR szDir[_MAX_DIR];
- ::GetModuleFileName(NULL, g_szModulePath, sizeof(g_szModulePath)/sizeof(TCHAR));
- _stprintf_s(g_szModuleFileName,_T("%s"),g_szModulePath);
- _tsplitpath(g_szModulePath, szDrive, szDir, NULL, NULL);
- _tcscpy_s(g_szModulePath, szDrive);
- _tcscat_s(g_szModulePath, szDir);
-
- char szFileName[MAX_PATH];
- #ifdef UNICODE
- sprintf_s(szFileName, "%sSMSlogcfg.xml", CW2A(g_szModulePath));
- #else
- sprintf_s(szFileName, "%sSMSlogcfg.xml", g_szModulePath);
- #endif
-
- LOG4C_PARAM_CFG_FILE_NAME(szFileName);
-
- LOG4C_PARAM_LOG_FILE_NAME("SMSlog");
-
- LOG4C_PARAM_LOG_LEVEL("unknown");
-
- LOG4C_PARAM_LOG_FILE_SIZE(2097152);
-
- LOG4C_PARAM_LOG_FILE_NUM(10);
-
- LOG4C_PARAM_REREAD_LOG_CFG_FILE(1);
-
- LOG4C_INIT_WITH_PARAM();
- LOG4C_NO_FILENUM((LOG_NOTICE,"启动log日志"));
-
-
-
-
-
-
-
-
- SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
- #if JEFF_TEST_ON
- if(GetSysIniInfo() == -1)
- {
-
- if ( GetSysIniInfo2() == -1)
- {
- AfxMessageBox(_T("没有找到配置文件"));
- return FALSE;
- }
-
- g_nVersion = g_dwEncryType;
- }
- else
- {
- _tcscpy_s(g_szSMSServer,_T("liyafangzhou.eicp.net"));
- g_dwTCPSMSPort = 8600;
- if(GetSoftWareVersion() == -1)
- {
- AfxMessageBox(_T("没有找到加密狗,请确认是否有加密狗!"));
- return FALSE;
- }
- }
-
- WSADATA WSAData = { 0 };
- if(0 != WSAStartup(MAKEWORD(2, 2), &WSAData))
- {
- AfxMessageBox(_T("网络环境初始化失败!"));
- return FALSE;
- }
- else
- {
- DWORD dwServerIP = 0;
- #ifdef UNICODE
- char szHost[MAX_PATH] = {0};
- strcpy_s(szHost,CW2A(g_szSMSServer));
- HOSTENT *host = gethostbyname(szHost);
- #else
- HOSTENT *host = gethostbyname(g_szSMSServer);
- #endif
- struct in_addr addr;
- if (host != NULL)
- {
-
- CString strSvrIP = _T("");
- for (int i = 0; host->h_addr_list[i] != NULL; i++)
- {
- memset(&addr, 0, sizeof(addr));
- memcpy(&addr.S_un.S_addr, host->h_addr_list[i], host->h_length);
- dwServerIP = ntohl(addr.S_un.S_addr);
- BYTE* pIP = (BYTE*)&dwServerIP;
- g_strServerIP.Format(_T("%d.%d.%d.%d"), pIP[3], pIP[2], pIP[1], pIP[0]);
- #ifdef UNICODE
- LOG4C_NO_FILENUM((LOG_NOTICE,"域名IP:%s",(char*)CW2A(g_strServerIP)));
- #else
- LOG4C_NO_FILENUM((LOG_NOTICE,"域名IP:%s",g_strServerIP));
- #endif
- break;
- }
- }
- else
- {
- LOG4C_NO_FILENUM((LOG_NOTICE,"DNS服务器解析域名IP失败,有可能是服务器DNS异常,请使用360等工具修复!"));
- }
- }
- #endif
- ClyfzSMSHandleDlg dlg;
- m_pMainWnd = &dlg;
- INT_PTR nResponse = dlg.DoModal();
- if (nResponse == IDOK)
- {
-
-
- }
- else if (nResponse == IDCANCEL)
- {
-
-
- }
-
-
- return FALSE;
- }
- int ClyfzSMSHandleApp::ExitInstance()
- {
-
- LOG4C_NO_FILENUM((LOG_NOTICE,"退出log日志"));
- LOG4C_FINI();
- CloseHandle(g_hMutex);
- return CWinAppEx::ExitInstance();
- }
|