Home > Back-end >  Answer genuflect is begged...
Answer genuflect is begged...

Time:10-06

How can't write into the service manager? ,,,,,,,,,


#include
#include

Int main ()
{
SC_HANDLE hSCM=OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS);
If (NULL==hSCM)
return false;
SC_HANDLE hSCService=OpenService (hSCM, (LPCWSTR) "calc," SERVICE_ALL_ACCESS);
If (hSCService==NULL)
SC_HANDLE hSCService=CreateService (hSCM (LPCWSTR) "calc", (LPCWSTR) "calc SERVICE_ALL_ACCESS, 10, 2, 1, (LPCWSTR)" C: \ \ WINDOWS \ \ system32 \ \ calc exe ", NULL, NULL, NULL, NULL, NULL);


//SC_HANDLE hSCService=CreateService (hSCM, "calc", "calc SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL," C: \ \ Windows \ \ system32 \ \ calc exe ", NULL, NULL, NULL, NULL, NULL);
If (hSCService==NULL)
{
Int m=GetLastError ();
Printf (" % d \ n ", m);
return false;
}
BOOL bRet=StartService (hSCService, 0, NULL);
If (bRet!=NULL)
{
Printf (" success ");
}
The else
{
Int n=GetLastError ();
Printf (" % d \ n ", n);
}

CloseServiceHandle (hSCService);
CloseServiceHandle (hSCM);
system("pause");
return 0;

}
  • Related