📄 ntservapp.cpp
字号:
// NTService.cpp
//
// This is the main program file containing the entry point.
#include "NTServApp.h"
#include "myservice.h"
int main(int argc, char* argv[])
{
// Create the service object
CMyService MyService;
// Parse for standard arguments (install, uninstall, version etc.)
if (!MyService.ParseStandardArgs(argc, argv)) {
// Didn't find any standard args so start the service
// Uncomment the DebugBreak line below to enter the debugger
// when the service is started.
//DebugBreak();
MyService.StartService();
}
// When we get here, the service has been stopped
return MyService.m_Status.dwWin32ExitCode;
}
void AddLog(const char* format,...)
{
FILE* pfLog;
char current[36];
char tp[36];
struct _timeb timebuffer;
char lpFileName[MAX_PATH];
_strdate(current);
_ftime(&timebuffer);
strcpy(tp,ctime(&(timebuffer.time)));
current[2]='_';
current[5]=0;
tp[strlen(tp)-1]=0;
GetModuleFileName(NULL,lpFileName,MAX_PATH);
sprintf(strrchr(lpFileName,'\\')+1,
"Service%s_%.2s.txt\0",strrchr(tp,' ')+1,current);
current[2]='-';
tp[strrchr(tp,' ')-tp]=0;
pfLog=fopen(lpFileName,"a");
va_list args;
va_start(args,format);
#if _DEBUG
vfprintf(stdout,format,args);
#endif
fprintf(pfLog,"%s<%s.%.3u> ",current,
strrchr(tp,' ')+1,timebuffer.millitm);
vfprintf(pfLog,format,args);
va_end(args);
fflush(pfLog);
fclose(pfLog);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -