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


C++ CNTService::SetServiceStatus方法代码示例

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


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

示例1: service_ctrl

//	PURPOSE:  This function is called by the SCM whenever ControlService() is called on this service.  The
//		SCM does not start the service through this function.
void WINAPI CNTService::service_ctrl(DWORD dwCtrlCode) // static
{
	if ( dwCtrlCode == SERVICE_CONTROL_STOP )
		g_Service.ServiceStop();
	g_Service.SetServiceStatus(g_Service.m_sStatus.dwCurrentState, NO_ERROR, 0);
}
开发者ID:DarkLotus,项目名称:Source,代码行数:8,代码来源:ntservice.cpp

示例2: WinMain

/////////////////////////////////////////////////////////////////////////////////////
//
//	FUNCTION: main()
//
/////////////////////////////////////////////////////////////////////////////////////
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);

	TCHAR	*argv[32];
	argv[0] = NULL;
	int argc = Str_ParseCmds(lpCmdLine, &argv[1], COUNTOF(argv)-1, " \t") + 1;

	if ( GRAY_GetOSInfo()->dwPlatformId != VER_PLATFORM_WIN32_NT )
	{
		// We are running Win9x - So we are not an NT service.
do_not_nt_service:
		NTWindow_Init(hInstance, lpCmdLine, nCmdShow);
		int iRet = Sphere_MainEntryPoint(argc, argv);
		NTWindow_Exit();
		TerminateProcess(GetCurrentProcess(), iRet);
		return iRet;
	}

	// We need to find out what the server name is....look it up in the .ini file
	if ( !g_Cfg.LoadIni(true) )
	{
		// Try to determine the name and path of this application.
		char szPath[_MAX_PATH];

		GetModuleFileName(NULL, szPath, sizeof(szPath));

		if ( !szPath[0] )
			return -2;

		ExtractPath(szPath);
		g_Cfg.LoadIni(false);
	}

	if ( !g_Cfg.m_fUseNTService )	// since there is no way to detect how did we start, use config for that
		goto do_not_nt_service;

	g_Service.SetServiceStatus(SERVICE_START_PENDING, NO_ERROR, 5000);

	// process the command line arguments...
	if (( argc > 1 ) && _IS_SWITCH(*argv[1]) )
	{
		if ( argv[1][1] == 'k' )		// service control
		{
			if ( argc < 3 )
			{
				printf("Use \"-k command\" with operation to proceed (install/remove)\n");
			}
			else if ( !strcmp(argv[2], "install") )
			{
				g_Service.CmdInstallService();
			}
			else if ( !strcmp(argv[2], "remove") )
			{
				g_Service.CmdRemoveService();
			}
			return 0;
		}
	}

	// If the argument does not match any of the above parameters, the Service Control Manager (SCM) may
	// be attempting to start the service, so we must call StartServiceCtrlDispatcher.
	g_Service.ReportEvent(EVENTLOG_INFORMATION_TYPE, 0, "Starting Service.");

	g_Service.CmdMainStart();
	g_Service.SetServiceStatus(SERVICE_STOPPED, NO_ERROR, 0);
	return -1;
}
开发者ID:DarkLotus,项目名称:Source,代码行数:73,代码来源:ntservice.cpp


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