Esempio n. 1
0
// CIdlePreventApp initialization
BOOL CIdlePreventApp::InitInstance()
{
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

	// Is another instance running?
	if (g_SingleInstanceObj.IsAnotherInstanceRunning())
	{
		AfxMessageBox(_T("Program is already running."), MB_OK|MB_ICONERROR, 0);
		return FALSE;
	}
	
	CIdlePreventDlg dlg;
	m_pMainWnd = &dlg;
	dlg.DoModal();
	return FALSE;
}
Esempio n. 2
0
BOOL CHookSrvApp::InitInstance()
{
	BOOL bIsAnotherInstanceRunning = 
		g_SingleInstanceObj.IsAnotherInstanceRunning();

	if (!bIsAnotherInstanceRunning)
	{
		#ifdef _AFXDLL
			Enable3dControls();			// Call this when using MFC in a shared DLL
		#else
			Enable3dControlsStatic();	// Call this when linking to MFC statically
		#endif
		// To create the main window, this code creates a new frame window
		// object and then sets it as the application's main window object.
		CMainFrame* pFrame = new CMainFrame;
		m_pMainWnd = pFrame;
		// create and load the frame with its resources
		pFrame->LoadFrame(
			IDR_MAINFRAME,
			WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, 
			NULL,
			NULL
			);

		// The one and only window has been initialized, so show and update it.
		pFrame->ShowWindow(SW_HIDE);
		pFrame->UpdateWindow();
	} // if

	return (!bIsAnotherInstanceRunning);
}
Esempio n. 3
0
// ignore parameters in this sample service
void CSpacService :: Run(DWORD, LPTSTR *) {
	if (g_SingleInstanceObj.IsAnotherInstanceRunning()){
		utils_error("Another PMCSpac Daemon instance is already running.\n");
		return;
	}
	
	// report to the SCM that we're about to start
	utils_trace("Starting PMC Serial Port Access Coordinator Version 1.0...\n");
	ReportStatus(SERVICE_START_PENDING);
	
	m_hStop = ::CreateEvent(0, FALSE, FALSE, 0);
	SECURITY_ATTRIBUTES sd;
	ZeroMemory(&sd, sizeof(sd));
	sd.nLength = sizeof(sd);
	m_hRestart = ::CreateEvent(&sd, FALSE, FALSE, SPAC_RESET_EVENT);
	HANDLE handles[2];
	handles[0] = m_hStop;
	handles[1] = m_hRestart;
	// You might do some more initialization here.
	// Parameter processing for instance ...
	utils_trace("PMC Serial Port Access Coordinator Version 1.0 started...\n");
	init();
	// enter main-loop
	// If the Stop() method sets the event, then we will break out of
	// this loop.
	// report SERVICE_RUNNING immediately before you enter the main-loop
	// DON'T FORGET THIS!
	ReportStatus(SERVICE_RUNNING);	
	bool bStop = false;
	while(!bStop){
		switch(MsgWaitForMultipleObjects(2,handles,false,INFINITE,QS_ALLEVENTS) ){
		case WAIT_OBJECT_0:
			bStop = true;
			break;
		case WAIT_OBJECT_0 + 1:
			_restart();
			break;
		case WAIT_OBJECT_0 + 2:
			MSG msg;
			while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)){
				TranslateMessage(&msg);
				DispatchMessage(&msg);
				break;
			}
		}
	}
	if( m_hStop )	::CloseHandle(m_hStop);
	uninit();
	ReportStatus(SERVICE_STOPPED);
}
Esempio n. 4
0
int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

    if(g_SingleInstanceObj.IsAnotherInstanceRunning())
		return FALSE;

 	// Load up the DLL, start vent, set the hook, etc.
	if(!InitializepreVentrilo())
		return FALSE;

	MSG msg;
	HACCEL hAccelTable;

	// Initialize global strings
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	LoadString(hInstance, IDC_PREVENTRILO, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance);

	// Perform application initialization:
	if (!InitInstance (hInstance, nCmdShow))
	{
		return FALSE;
	}

    hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_PREVENTRILO));

	// Load the menu
	hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDC_PREVENTRILO));
	hMenu = GetSubMenu(hMenu, 0);

	// Main message loop:
	while (GetMessage(&msg, NULL, 0, 0))
	{
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	return (int) msg.wParam;
}
Esempio n. 5
0
BOOL CGSnapApp::InitInstance()
{
	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

	CoInitialize(NULL);

	// single instance
	if (g_SingleInstanceObj.IsAnotherInstanceRunning()) 
		return FALSE;

	CGSnapDlg 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;
}
Esempio n. 6
0
// CALApp initialization
BOOL CALApp::InitInstance()
{
    // this call will popup onother instance if is running
    if (g_SingleInstanceObj.IsAnotherInstanceRunning())
    {
        return FALSE;
    }

    // Register and exit if it fails
    if (!g_SingleInstanceObj.RegisterInstance())
    {
        TRACE("Class Registration Failed\n");
        return FALSE;
    }

    // InitCommonControlsEx() is required on Windows XP if an application
    // manifest specifies use of ComCtl32.dll version 6 or later to enable
    // visual styles.  Otherwise, any window creation will fail.
    INITCOMMONCONTROLSEX InitCtrls;
    InitCtrls.dwSize = sizeof(InitCtrls);
    // Set this to include all the common control classes you want to use
    // in your application.
    InitCtrls.dwICC = ICC_WIN95_CLASSES;
    InitCommonControlsEx(&InitCtrls);

    CWinApp::InitInstance();

    // Initialize OLE libraries
    if (!AfxOleInit())
    {
        AfxMessageBox(IDP_OLE_INIT_FAILED);
        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
    // Change the registry key under which our settings are stored
    // TODO: You should modify this string to be something appropriate
    // such as the name of your company or organization
    SetRegistryKey(_T("ActiveLog"));

    // DO WE HAVE THIS ???
    //LoadStdProfileSettings(4);  // Load standard INI file options (including MRU)
    //If nMaxMRU is 0, no MRU list will be maintained.
    LoadStdProfileSettings(0);

    WINDOWPLACEMENT wp;
    if (ReadWindowPlacement(&wp))
    {
        if (wp.flags & WPF_RESTORETOMAXIMIZED)
            m_nCmdShow = SW_SHOWMAXIMIZED;
    }

    // Register the application's document templates.  Document templates
    //  serve as the connection between documents, frame windows and views
    CSingleDocTemplate* pDocTemplate;
    pDocTemplate = new CSingleDocTemplate(
        IDR_MAINFRAME,
        RUNTIME_CLASS(CALDoc),
        RUNTIME_CLASS(CMainFrame),       // main SDI frame window
        RUNTIME_CLASS(CLeftView));
    if (!pDocTemplate)
        return FALSE;
    AddDocTemplate(pDocTemplate);

    // Parse command line for standard shell commands, DDE, file open
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);

    // http://support.microsoft.com/kb/q129095/
    // info about reg type and names

    // App was launched with /Embedding or /Automation switch.
    // Run app as automation server.
    if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
    {
        // Register all OLE server factories as running.  This enables the
        //  OLE libraries to create objects from other applications
        COleTemplateServer::RegisterAll();

        // WORKAROUND - TO INITIALIZE DOC-VIEW
        // Don't show the main window
        //return TRUE;
    }
    // App was launched with /Unregserver or /Unregister switch.  Unregister
    // typelibrary.  Other unregistration occurs in ProcessShellCommand().
    else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
    {
        //FALSE results in unregistering all COM objects implemented as
        //CCmdTarget derived classes.
        COleObjectFactory::UpdateRegistryAll(FALSE);
        AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor);
    }
    // App was launched standalone or with other switches (e.g. /Register
    // or /Regserver).  Update registry entries, including typelibrary.
    else
    {
        COleObjectFactory::UpdateRegistryAll();
        // Register all OLE server factories as running.  This enables the
        //  OLE libraries to create objects from other applications
        COleTemplateServer::RegisterAll();
        AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid);
    }

    // warning C6214: Cast between semantically different integer types: HRESULT to a Boolean type
    // move this to setup application ???

    // v.0.09.02 - fix for Vista
    // do not exit application, this job has been moved to installation
    RegisterSafeScripting();

    // Dispatch commands specified on the command line.  Will return FALSE if
    // app was launched with /RegServer, /Register, /Unregserver or /Unregister.
    if (!ProcessShellCommand(cmdInfo))
        return FALSE;

    // The one and only window has been initialized, so show and update it
    m_pMainWnd->ShowWindow(SW_SHOW);
    m_pMainWnd->UpdateWindow();
    // call DragAcceptFiles only if there's a suffix
    //  In an SDI app, this should occur after ProcessShellCommand
    return TRUE;
}
Esempio n. 7
0
// CViewBarApp initialization
BOOL CViewBarApp::InitInstance()
{
	//enable leak check
#ifdef DEBUG
	_CrtSetDbgFlag( _CRTDBG_REPORT_FLAG); 
#endif
	

	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

	AfxEnableControlContainer();

	// single instance, esp. for XP users
	if (LockFile() == FALSE)
	{
		//CString msg, title;
		//msg.LoadString(IDS_WARNING_MULTIINTANCE);

		//AfxMessageBox(msg, MB_ICONWARNING);

		CAppBarManager::GetInstance()->OnMultiInstance();

		return FALSE;
	}


	// 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
	// Change the registry key under which our settings are stored
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization
	SetRegistryKey(_T("Agloco Viewbar"));

	// initialize com
	CoInitialize(NULL);


	thePrefs.LoadConfigFromRegistry();

//#ifdef DEBUG
	g_log.Open(_T("log.txt"));
//#endif

	// single instance
	if (g_SingleInstanceObj.IsAnotherInstanceRunning()) 
		return FALSE;

	//// Update
	//CUpdater updater;
	//updater.AutoUpdate();

	// initialization
	CUISubject::GetInstance();

	// lang
	CLangManager::GetInstance()->GetDefaultLanguage();

	// skin
	CSkinManager::GetInstance();

	// ViewBar session
	http::CVBSession::GetInstance();

	// SearchEngine
	CSearchManager::GetInstance();

	// Advertisement
	CAdsManager::GetInstance();

	// SQLite
	CCppSQLiteManager::GetInstance();

	// Appbar Manager
	CAppBarManager::GetInstance();

	CDataStore::GetInstance();

	CMyUtility::m_uProcessMsg = RegisterWindowMessage(_T("78910EFA-50F9-4f7d-A66E-A8365C60140B"));
	
	GetUserInfo();

	CDlgLogin dlg;

	if (IsAutoLogin())
	{
		dlg.SetAutoLogin();
	}
	m_pMainWnd = &dlg;

	// log
	g_log.OutputDebug(_T("++++++++++++++++++++++++++++++++++++++++++++++APPLICATION START+++++++++++++++++++++++++++++++++++++++++++++++"));

	INT_PTR 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;
}