PPTtimer.cpp
资源名称:PPTtimer.rar [点击查看]
上传用户:chpname
上传日期:2018-11-08
资源大小:69k
文件大小:3k
源码类别:
对话框与窗口
开发平台:
Visual C++
- // PPTtimer.cpp : Defines the class behaviors for the application.
- //
- #include "stdafx.h"
- #include "PPTtimer.h"
- #include "PPTtimerDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CPPTtimerApp
- BEGIN_MESSAGE_MAP(CPPTtimerApp, CWinApp)
- //{{AFX_MSG_MAP(CPPTtimerApp)
- // 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()
- /////////////////////////////////////////////////////////////////////////////
- // CPPTtimerApp construction
- CPPTtimerApp::CPPTtimerApp()
- {
- // TODO: add construction code here,
- // Place all significant initialization in InitInstance
- }
- /////////////////////////////////////////////////////////////////////////////
- // The one and only CPPTtimerApp object
- CPPTtimerApp theApp;
- HANDLE hmutex;//禁止程序重复运行的互斥量句柄
- /////////////////////////////////////////////////////////////////////////////
- // CPPTtimerApp initialization
- BOOL CPPTtimerApp::InitInstance()
- {
- // 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.
- AfxEnableControlContainer();
- //设置背景颜色
- SetDialogBkColor(RGB(255,255,128));//RGB(4,227,88));
- //禁制程序重复运行
- char appName[MAX_PATH];
- char appTitle[20]="", title[17]="";
- int i,j;
- ::GetModuleFileName(NULL,appName,MAX_PATH);
- ::GetFileTitle(appName,appTitle,20);
- for(i=0;i<=20;i++)
- {
- if((appTitle[i]=='.') && (appTitle[i+1]=='e') && (appTitle[i+2]=='x') && (appTitle[i+3]=='e'))
- {
- for(j=0;j<i;j++)
- {
- title[j]=appTitle[j];
- }
- break;
- }
- }
- hmutex=CreateMutex(NULL,TRUE,title);
- if(GetLastError()==ERROR_ALREADY_EXISTS)
- {
- MessageBox(NULL,"程序已经运行了","infor",MB_OK);
- return FALSE;
- }
- CPPTtimerDlg 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;
- }