www.gusucode.com > VC++挂机锁屏系统源程序源码程序 > VC++挂机锁屏系统源程序源码程序\code\LOCK.cpp
// LOCK.cpp : Defines the class behaviors for the application. // /*----------------------------------------------------------------------------*/ // // 文件: LOCKDlg.cpp // 版本: 1.0 // 作者: 蔡亦汤 // 创建时间: 2007 3 26 // EMAIL: caiyitang2003@163.com /*---------------------------------------------------------------------------- /* /* Copyright (C) 2007-2008 by LeoSoftware /* All Rights Reserved. /* /*----------------------------------------------------------------------------*/ #include "stdafx.h" #include "LOCK.h" #include "LOCKDlg.h" #include "SplashDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #define one "0x12345677, 0x77654321, 0xabcdef, 0xfedcba" //只能运行一个程序 HANDLE handle; ///////////////////////////////////////////////////////////////////////////// // CLOCKApp // Download by http://www.NewXing.com BEGIN_MESSAGE_MAP(CLOCKApp, CWinApp) //{{AFX_MSG_MAP(CLOCKApp) // 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() ///////////////////////////////////////////////////////////////////////////// // CLOCKApp construction CLOCKApp::CLOCKApp() { // TODO: add construction code here, // Place all significant initialization in InitInstance } ///////////////////////////////////////////////////////////////////////////// // The one and only CLOCKApp object CLOCKApp theApp; ///////////////////////////////////////////////////////////////////////////// // CLOCKApp initialization BOOL CLOCKApp::InitInstance() { //利用"互斥函数",判断本程序是否已经运行 handle=::CreateMutex(NULL,FALSE,one); if(GetLastError()==ERROR_ALREADY_EXISTS) { CWRONGDlg wrongdlg; //错误窗口提示 wrongdlg.m_strTitle.Format("欢迎使用小蔡软件!"); wrongdlg.m_strText.Format("对不起!\r\n本程序已经运行!"); wrongdlg.DoModal(); return FALSE; } AfxEnableControlContainer(); // 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 CSplashDlg *splashDlg=new CSplashDlg; splashDlg->Create(IDD_SPLASH,NULL); //新建启动窗口 splashDlg->ShowWindow(SW_SHOW); //显示启动窗口 splashDlg->UpdateWindow(); CLOCKDlg 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 CLOCKApp::ExitInstance() { // TODO: Add your specialized code here and/or call the base class //为了安全,在系统退出后还原所有禁止的东西 CTaskKeyMgr::Disable(CTaskKeyMgr::ALL, FALSE); return 0; //return CWinApp::ExitInstance(); }