本文整理汇总了C++中CNTService::ReportEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ CNTService::ReportEvent方法的具体用法?C++ CNTService::ReportEvent怎么用?C++ CNTService::ReportEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNTService
的用法示例。
在下文中一共展示了CNTService::ReportEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}