SmsCenter/SmsCenter.cpp

140 lines
3.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// SmsCenter.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "SmsCenter.h"
#include "SmsCenterDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSmsCenterApp
#include <Psapi.h>
#include "..\public\MiniDmp\MiniDmp.h"
BEGIN_MESSAGE_MAP(CSmsCenterApp, CWinApp)
//{{AFX_MSG_MAP(CSmsCenterApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSmsCenterApp construction
CSmsCenterApp::CSmsCenterApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CSmsCenterApp object
CSmsCenterApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CSmsCenterApp initialization
//#include "..\..\shou-e\RN_Eri\blowfish_Eri.h"
BOOL CSmsCenterApp::InitInstance()
{
/*
int a = sizeof(long);
int b = sizeof(float);
int c = sizeof(double);
int d=sizeof(UCHAR);
int e=sizeof(int);
*/
//设置异常捕捉程序生成minidump文件
//#if _MSC_VER>=1300
//#ifdef _M_IX86
#ifndef _DEBUG
GPTSetSetUnhandledExceptionFilter(); //启用错误拦截
#endif
//#endif
//#endif
AfxEnableControlContainer();
//CoInitialize(NULL);
CoInitializeEx( NULL , COINIT_MULTITHREADED );
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
/*
if ( FindProcess(_T("SmsCenter.exe"))>1 )
{
int iRet = MessageBox(NULL,_T("已启动了短信服务器监控程序,可能处于不同的用户,请检查!\r\n是否继续启动") , _T("提问") , MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 );
if ( iRet != IDYES )
return false;
}
*/
CSmsCenterDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
int CSmsCenterApp::ExitInstance()
{
CoUninitialize();
return CWinApp::ExitInstance();
}
long CSmsCenterApp::FindProcess(const TCHAR *pName)
{
long lCount=0;
BOOL bReBoot = false;
DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;
//枚举系统进程ID列表
if ( EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
{
// Calculate how many process identifiers were returned.
//计算进程数量
cProcesses = cbNeeded / sizeof(DWORD);
// 输出每个进程的名称和ID
TCHAR szProcessName[MAX_PATH]={0};
for ( i = 0; i < cProcesses; i++ )
{
memset( szProcessName ,0, sizeof(szProcessName) );
CSmsCenterDlg::GetProcessNameAndID( aProcesses[i],szProcessName);
//if ( !strcmp( szProcessName , pName ) ) //查找Dh2000的进程名
if ( !_tcsncmp( szProcessName , pName , _tcslen(pName) ) ) //查找Dh2000的进程名
{
lCount ++;
}
}
}
return lCount;
}