当前位置: 首页>>代码示例>>C++>>正文


C++ CCmdLine::HasParam方法代码示例

本文整理汇总了C++中CCmdLine::HasParam方法的典型用法代码示例。如果您正苦于以下问题:C++ CCmdLine::HasParam方法的具体用法?C++ CCmdLine::HasParam怎么用?C++ CCmdLine::HasParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCmdLine的用法示例。


在下文中一共展示了CCmdLine::HasParam方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: InitInstance

//--------------------------------------------------------------------------------
BOOL CSecurityServerApp::InitInstance()
	{
	BOOL b = ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS);

	if (!AfxSocketInit())
		{
		AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
		return FALSE;
		}

	g_hSingletonMutex = ::CreateMutex(NULL, FALSE, "MCMSSecurityServerSingletonMutex");
	if(g_hSingletonMutex == NULL || GetLastError() == ERROR_ALREADY_EXISTS)
		{
#ifndef _NOT_A_SERVICE
		g_service.AddToMessageLog(_T("SecurityServer already running."));
#endif
		TRACE("SecurityServer already running\n");
		return FALSE;
		}

	// create an invisible window
	m_pMainWnd = new CWnd;
	m_pMainWnd->CreateEx(0, AfxRegisterWndClass(NULL), NULL, 0, 0, 0, 0, 0, NULL, NULL);

	AfxEnableControlContainer();

#ifdef _NOT_A_SERVICE

	m_pSystem = new CSecuritySystem;
	m_pSystem->GetIOSubSystem()->CreateLogFile("C:\\SStest.log", false);
	m_pSystem->GetIOSubSystem()->SetTraceLevel(IOMASK_1|IOMASK_2|IOMASK_3|IOMASK_4|IOMASK_5|IOMASK_6);

	m_pServiceThread = ::AfxBeginThread((AFX_THREADPROC) ServiceThread, (LPVOID) this);
	return TRUE;

#else
	CCmdLine cmdLine;

	int nIndex;
	if(cmdLine.HasParam('I', nIndex) || cmdLine.HasParam("-install", nIndex))
		g_service.InstallService();
	else
		if(cmdLine.HasParam('R', nIndex) || cmdLine.HasParam("-remove", nIndex))
			g_service.RemoveService();
		else
			if(cmdLine.HasParam('E', nIndex) || cmdLine.HasParam("-end", nIndex) || cmdLine.HasParam("-stop", nIndex))
				g_service.EndService();
			else
				{
				// must start the system first
				m_pSystem = new CSecuritySystem;
				if(m_pSystem->GetResultCode() != CResult::noErr)
					g_service.AddToMessageLog(_T("Exception occured during SecurityServer startup.  Check license file validity."));

				CSSConfigPerformance config;
				m_pSystem->GetIOSubSystem()->SetTraceLevel(config.m_nTraceLevel);

				m_pServiceThread = ::AfxBeginThread((AFX_THREADPROC) ServiceThread, (LPVOID) this);
				::Sleep(1000);
				g_service.ReportStatus(SERVICE_RUNNING);
				// dont destroy the window cuz we'll need it
				return TRUE;
				}

	// we dont need this window
	delete m_pMainWnd;
	m_pMainWnd = NULL;

	return FALSE;
#endif // _DEBUG
	}
开发者ID:moosethemooche,项目名称:Certificate-Server,代码行数:72,代码来源:SecurityServer.cpp


注:本文中的CCmdLine::HasParam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。