Bosses help look at what is going wrong???????
Or there is something wrong with the DLL file?
Dllmain. CPP:
Service. H:
# pragma once
# include "stdafx. H"
DWORD WINAPI ServiceHandler (DWORD dwControl, dwords dwEventType LPVOID lpEventData, LPVOID lpContext);
# ifdef __cplusplus
Extern "C"
{
# endif
__declspec (dllexport) VOID WINAPI ServiceMain (DWORD dwArgc, LPCTSTR * lpszArgv);
# ifdef __cplusplus
}
# endif
Service. The CPP:
//service. The CPP: defines the DLL export function of the application,
//
# include "service. H"
# include "stdafx. H"
SERVICE_STATUS_HANDLE g_service_status_handle=NULL;
SERVICE_STATUS g_service_status=
{
SERVICE_WIN32_SHARE_PROCESS,
SERVICE_START_PENDING,
SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_PAUSE_CONTINUE
};
DWORD WINAPI ServiceHandler (DWORD dwControl, dwords dwEventType LPVOID lpEventData, LPVOID lpContext)
{
The switch (dwControl)
{
Case SERVICE_CONTROL_STOP:
Case SERVICE_CONTROL_SHUTDOWN:
G_service_status. DwCurrentState=SERVICE_STOPPED;
break;
Case SERVICE_CONTROL_PAUSE:
G_service_status. DwCurrentState=SERVICE_PAUSED;
break;
Case SERVICE_CONTROL_CONTINUE:
G_service_status. DwCurrentState=SERVICE_RUNNING;
break;
Case SERVICE_CONTROL_INTERROGATE:
break;
Default:
break;
};
SetServiceStatus (g_service_status_handle, & amp; G_service_status);
Return NO_ERROR.
}
Extern "C" __declspec (dllexport) VOID WINAPI ServiceMain (DWORD dwArgc, LPCTSTR * lpszArgv)
{
Svchost g_service_status_handle=RegisterServiceCtrlHandlerEx (TEXT (" Service "), ServiceHandler, NULL);
if (! G_service_status_handle)
{
return;
}
G_service_status. DwCurrentState=SERVICE_RUNNING;
SetServiceStatus (g_service_status_handle, & amp; G_service_status);
While (TRUE)
{
Sleep (1000);
OutputDebugString (TEXT (" Hello Topsec Svchost In "));
}
return;
};
CodePudding user response:
Baidu search "Session0 through"CodePudding user response:
Set path % SystemRoot % directly to C: \ Windows give it a try