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


C++ DeleteService函数代码示例

本文整理汇总了C++中DeleteService函数的典型用法代码示例。如果您正苦于以下问题:C++ DeleteService函数的具体用法?C++ DeleteService怎么用?C++ DeleteService使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: OpenSCManager

__int64 WinPmem::uninstall_driver() {
  SC_HANDLE scm, service;
  SERVICE_STATUS ServiceStatus;

  scm = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);

  if (!scm) return 0;

  service = OpenService(scm, service_name, SERVICE_ALL_ACCESS);

  if (service) {
    ControlService(service, SERVICE_CONTROL_STOP, &ServiceStatus);
  };

  DeleteService(service);
  CloseServiceHandle(service);
  Log(TEXT("Driver Unloaded.\n"));

  return 1;

  CloseServiceHandle(scm);
  return 0;
}
开发者ID:queer1,项目名称:rekall,代码行数:23,代码来源:winpmem.cpp

示例2: WinServiceUninstall

bool WinServiceUninstall()
{
    SC_HANDLE serviceControlManager = OpenSCManager(0, 0, SC_MANAGER_CONNECT);

    if (serviceControlManager)
    {
        SC_HANDLE service = OpenService(serviceControlManager,
            serviceName, SERVICE_QUERY_STATUS | DELETE);
        if (service)
        {
            SERVICE_STATUS serviceStatus2;
            if (QueryServiceStatus(service, &serviceStatus2))
            {
                if (serviceStatus2.dwCurrentState == SERVICE_STOPPED)
                    DeleteService(service);
            }
            CloseServiceHandle(service);
        }

        CloseServiceHandle(serviceControlManager);
    }
    return true;
}
开发者ID:8Infinity8,项目名称:InfinityCore,代码行数:23,代码来源:ServiceWin32.cpp

示例3: wsvc_remove

/* Remove installed service from servicecontrolmanager */
void
wsvc_remove(FILE* out)
{
        SC_HANDLE scm;
        SC_HANDLE sv;
        if(out) fprintf(out, "removing unbound service\n");
        scm = OpenSCManager(NULL, NULL, (int)SC_MANAGER_ALL_ACCESS);
        if(!scm) fatal_win(out, "could not OpenSCManager");
        sv = OpenService(scm, SERVICE_NAME, DELETE);
        if(!sv) {
                CloseServiceHandle(scm);
                fatal_win(out, "could not OpenService");
        }
        if(!DeleteService(sv)) {
		CloseServiceHandle(sv);
		CloseServiceHandle(scm);
                fatal_win(out, "could not DeleteService");
        }
        CloseServiceHandle(sv);
        CloseServiceHandle(scm);
	event_reg_remove(out);
        if(out) fprintf(out, "unbound service removed\n");
}
开发者ID:chigumaya,项目名称:unbound,代码行数:24,代码来源:w_inst.c

示例4: remove_service

static BOOL remove_service(void){
  SC_HANDLE scm;
  SC_HANDLE service;
  if((scm = OpenSCManager(NULL, 
			  NULL,  
			  GENERIC_WRITE))
     == NULL)
    return FALSE;
  service = OpenServiceW(scm,
			 real_service_name,
			 SERVICE_ALL_ACCESS);
  if(service == NULL){
    CloseServiceHandle(scm);
    return FALSE;
  }
  if(!DeleteService(service)){
    last_error = GetLastError();
    return FALSE;
  }
  CloseServiceHandle(service);
  CloseServiceHandle(scm);
  return TRUE;
}
开发者ID:0x00evil,项目名称:otp,代码行数:23,代码来源:erlsrv_interactive.c

示例5: remove_service

static void remove_service(SC_HANDLE hSCManager, SC_HANDLE hService, char* name, char* disp_name)
{
	SERVICE_STATUS	status;

	printf("Removing service: %-40s ... ", disp_name);

	if(hService==NULL) {

		hService = OpenService(hSCManager, name, SERVICE_ALL_ACCESS);

		if(hService==NULL) {
			printf("\n!ERROR %d opening service: %s\n",GetLastError(),name);
			return;
		}
	}

    // try to stop the service
    if(ControlService( hService, SERVICE_CONTROL_STOP, &status))
    {
        printf("\nStopping: %s ... ",name);

        while(QueryServiceStatus(hService, &status) && status.dwCurrentState == SERVICE_STOP_PENDING)
			Sleep(1000);

        if(status.dwCurrentState == SERVICE_STOPPED)
            printf("Stopped.\n");
        else
            printf("FAILED!\n");
    }

    // now remove the service
    if(DeleteService(hService))
		printf("Successful\n");
	else
		printf("!ERROR %d\n",GetLastError());
    CloseServiceHandle(hService);
}
开发者ID:K6BSD,项目名称:SBBSUnstable,代码行数:37,代码来源:sexpots.c

示例6: SvcDelete

void SvcDelete()
{
	SC_HANDLE schSCManager;
	SC_HANDLE schService;

	schSCManager = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);

	if (!schSCManager)
	{
		printf("OpendSCManager failed (%d)\n", GetLastError());
		return;
	}

	schService = OpenService(
		schSCManager,
		SVCNAME,
		DELETE);

	if (!schService)
	{
		printf("OpenService failed (%d)\n", GetLastError());
		CloseServiceHandle(schSCManager);
		return;
	}

	if (!DeleteService(schService))
	{
		printf("DeleteService failed (%d)\n", GetLastError());
	}
	else
	{
		printf("Servcie deleted successfully\n");
	}

	CloseServiceHandle(schService);
	CloseServiceHandle(schSCManager);
}
开发者ID:Jereq,项目名称:TagSystem,代码行数:37,代码来源:Service.cpp

示例7: UninstallService

static int UninstallService(const char * sServiceName) {
	SC_HANDLE schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
	     
	if(schSCManager == NULL) {
	    printf("OpenSCManager failed (%d)!", GetLastError());
	    return EXIT_FAILURE;
	}
	
	SC_HANDLE schService = OpenService(schSCManager, sServiceName, SERVICE_QUERY_STATUS | SERVICE_STOP | DELETE);
	     
	if(schService == NULL) {
	    printf("OpenService failed (%d)!", GetLastError());
	    CloseServiceHandle(schSCManager);
	    return EXIT_FAILURE;
	}
	
	SERVICE_STATUS_PROCESS ssp;
	DWORD dwBytesNeeded;
	
	if(QueryServiceStatusEx(schService, SC_STATUS_PROCESS_INFO, (LPBYTE)&ssp, sizeof(SERVICE_STATUS_PROCESS), &dwBytesNeeded) != 0) {
	    if(ssp.dwCurrentState != SERVICE_STOPPED && ssp.dwCurrentState != SERVICE_STOP_PENDING) {
	        ControlService(schService, SERVICE_CONTROL_STOP, (LPSERVICE_STATUS)&ssp);
	    }
	}
	
	if(DeleteService(schService) == false) {
	    printf("DeleteService failed (%d)!", GetLastError());
	    CloseServiceHandle(schService);
	    CloseServiceHandle(schSCManager);
	    return EXIT_FAILURE;
	} else {
	    printf("PtokaX service '%s' deleted successfully.", sServiceName);
	    CloseServiceHandle(schService);
	    CloseServiceHandle(schSCManager);
	    return EXIT_SUCCESS;
	}
}
开发者ID:sidcode,项目名称:PtokaX,代码行数:37,代码来源:PtokaX-win.cpp

示例8: wisvc_UninstallKublService

void
wisvc_UninstallKublService (char **argv, char *service_name)
{
  int called_as_service = 0;	/* Needed by macro err_printf */
  SC_HANDLE schService = wisvc_OpenKublService (argv, service_name,
						"uninstall", DELETE);

  if (!DeleteService (schService))
    {
      DWORD erhe = GetLastError ();

      if (ERROR_SERVICE_MARKED_FOR_DELETE == erhe)
	{
	  err_printf ((
		 "%s: Cannot %s service \"%s\" because a service with that "
			"name still exists, although it has been marked for delete. Use ISQL to "
			"stop the old service with shutdown or raw_exit() before continuing "
			" (errno=%ld).\n",
			argv[0], "uninstall", service_name, erhe));
	}
      else
	{
	  err_printf ((
			"%s: Uninstalling service \"%s\" failed. "
			"DeleteService returned zero, errno=%ld.\n",
			argv[0], service_name, erhe));
	}
      exit (1);
    }
  else
    {
      err_printf (("%s: Service \"%s\" uninstalled successfully.\n",
		   argv[0], service_name));
    }

  CloseServiceHandle (schService);
}
开发者ID:China-ls,项目名称:virtuoso-opensource,代码行数:37,代码来源:wiservic.c

示例9: usblibOsDeleteService

/**
 * Deletes the service.
 *
 * @returns 0 on success.
 * @returns -1 on failure.
 */
int usblibOsDeleteService(void)
{
    /*
     * Assume it didn't exist, so we'll create the service.
     */
    int rc = -1;
    SC_HANDLE   hSMgr = OpenSCManager(NULL, NULL, SERVICE_CHANGE_CONFIG);
    DWORD LastError = GetLastError(); NOREF(LastError);
    AssertMsg(hSMgr, ("OpenSCManager(,,delete) failed rc=%d\n", LastError));
    if (hSMgr)
    {
        SC_HANDLE hService = OpenService(hSMgr, SERVICE_NAME, DELETE);
        if (hService)
        {
            /*
             * Delete the service.
             */
            if (DeleteService(hService))
                rc = 0;
            else
            {
                DWORD LastError = GetLastError(); NOREF(LastError);
                AssertMsgFailed(("DeleteService failed LastError=%Rwa\n", LastError));
            }
            CloseServiceHandle(hService);
        }
        else if (GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST)
            rc = 0;
        else
        {
            DWORD LastError = GetLastError(); NOREF(LastError);
            AssertMsgFailed(("OpenService failed LastError=%Rwa\n", LastError));
        }
        CloseServiceHandle(hSMgr);
    }
    return rc;
}
开发者ID:ryenus,项目名称:vbox,代码行数:43,代码来源:USBUninstall.cpp

示例10: UninstallService

VOID UninstallService()
{
	LOG_TRACE();
	SC_HANDLE hSCMgr = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
	if (NULL == hSCMgr)
	{
		std::cout << "Uninstall service failed. (OpenSCManager return null. GetLastError == " << GetLastError() << ")" << std::endl;
		LOG_RUN_ERROR("OpenSCManager failed. (%d)", GetLastError());
		return;
	}

	SC_HANDLE hSvc = OpenService(hSCMgr,MY_SERVICE_NAME, SERVICE_STOP | DELETE);
	if (NULL == hSvc)
	{
		std::cout << "Uninstall service failed. (OpenService return null. GetLastError == " << GetLastError() << ")" << std::endl;
		LOG_RUN_ERROR("CreateService failed. (%d)", GetLastError());
		CloseServiceHandle(hSCMgr);
		return;
	}

	//停止服务
	ControlService(hSvc, SERVICE_CONTROL_STOP, &g_svc_status);
	//删除服务
	if (DeleteService(hSvc))
	{
		LOG_RUN_DEBUG("Uninstall service success.");
		std::cout << "Uninstall service success." << std::endl;
	}
	else
	{
		LOG_RUN_DEBUG("DeleteService failed. (%d)", GetLastError());
		std::cout << "Uninstall service failed. (DeleteService return false. GetLastError == " << GetLastError() << ")" << std::endl;
	}

	CloseServiceHandle(hSvc);
	CloseServiceHandle(hSCMgr);
}
开发者ID:eSDK,项目名称:esdk_elte,代码行数:37,代码来源:eLTE_NativeService.cpp

示例11: OpenSCManager

void ServiceManager::UnInstall()
{
	SC_HANDLE schSCManager = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS); 
	if (schSCManager==0) 
	{
		long nError = GetLastError();
		TCHAR pTemp[121];
		_stprintf(pTemp, _T("OpenSCManager failed, error code = %d"), nError);
		LOG_WRITER_INSTANCE.WriteLog( pTemp);
	}
	else
	{
		SC_HANDLE schService = OpenService( schSCManager, SERVICE_PROPERTIES_INSTANCE.GetServiceName(), SERVICE_ALL_ACCESS);
		if (schService==0) 
		{
			long nError = GetLastError();
			TCHAR pTemp[121];
			_stprintf(pTemp, _T("OpenService failed, error code = %d"), nError);
			LOG_WRITER_INSTANCE.WriteLog( pTemp);
		}
		else
		{
			if(!DeleteService(schService)) 
			{
				TCHAR pTemp[121];
				_stprintf(pTemp, _T("Failed to delete service %s"), SERVICE_PROPERTIES_INSTANCE.GetServiceName());
				LOG_WRITER_INSTANCE.WriteLog( pTemp);
			}
			CloseServiceHandle(schService); 
		}
		CloseServiceHandle(schSCManager);	
	}

	CString logFileName=FolderHelper::GetModuleFileName().c_str();
	logFileName.Replace(_T(".exe"),_T(".log"));
	DeleteFile(logFileName);
}
开发者ID:Respublica,项目名称:EpWinService,代码行数:37,代码来源:epServiceManager.cpp

示例12: remove_symon

//  ------------------------------------------------------------------------
void remove_symon(void){					// Удаляем сервис из системы
    SC_HANDLE  hServiceControlManager, hService;
    if( NULL == ( hServiceControlManager = OpenSCManager( NULL, NULL, SC_MANAGER_CONNECT ))){
        fprintf( stderr, "ERROR-%u. Open SCM failed. Admin\n", GetLastError() );
        return;
    }
    if( NULL == ( hService = OpenService( hServiceControlManager, service_name, SERVICE_ALL_ACCESS | DELETE ))){
        fprintf( stderr, "ERROR-%u. Open service failed.\n", GetLastError() );
        CloseServiceHandle(hServiceControlManager);
        return;
    }
    if( !QueryServiceStatus( hService, &service_status )){
        fprintf( stderr, "ERROR-%u. Query service status failed.\n", GetLastError() );
        CloseServiceHandle(hServiceControlManager);
        CloseServiceHandle(hService);
        return;
    }
    if( service_status.dwCurrentState != SERVICE_STOPPED ){	// Если запущен - останавливаем
        fprintf( stderr, "WARNING! %u. Service is working. It will be stoped.\n", GetLastError() );
        if( !ControlService(hService, SERVICE_CONTROL_STOP, &service_status )){
            fprintf( stderr, "ERROR-%u. Control service failed.\n", GetLastError() );
            CloseServiceHandle(hServiceControlManager);
            CloseServiceHandle(hService);
            return;
        }
    Sleep(500);
    }
    if( !DeleteService( hService )){
        fprintf( stderr, "ERROR-%u. Delete service failed.\n", GetLastError() );
        CloseServiceHandle(hServiceControlManager);
        CloseServiceHandle(hService);
        return;
    }
    CloseServiceHandle(hServiceControlManager);
    CloseServiceHandle(hService);
    fprintf( stderr, "The service is deleted.\n" );	// Готово
}
开发者ID:MiZaRUs,项目名称:SessionMonitor,代码行数:38,代码来源:service.c

示例13: NTServiceUninstall

static int NTServiceUninstall( intf_thread_t *p_intf )
{
    intf_sys_t *p_sys  = p_intf->p_sys;

    SC_HANDLE handle = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );
    if( handle == NULL )
    {
        msg_Err( p_intf,
                 "could not connect to Services Control Manager database" );
        return VLC_EGENERIC;
    }

    /* First, open a handle to the service */
    SC_HANDLE service = OpenService( handle, p_sys->psz_service, DELETE );
    if( service == NULL )
    {
        msg_Err( p_intf, "could not open service" );
        CloseServiceHandle( handle );
        return VLC_EGENERIC;
    }

    /* Remove the service */
    if( !DeleteService( service ) )
    {
        msg_Err( p_intf, "could not delete service \"%s\"",
                 p_sys->psz_service );
    }
    else
    {
        msg_Dbg( p_intf, "service deleted successfuly" );
    }

    CloseServiceHandle( service );
    CloseServiceHandle( handle );

    return VLC_SUCCESS;
}
开发者ID:vlcchina,项目名称:vlc-player-experimental,代码行数:37,代码来源:ntservice.c

示例14: OpenSCManager

BOOL WindowsService::Remove()
{
  bool  ret_val= false;

  if (! IsInstalled())
    return true;

  // open a connection to the SCM
  SC_HANDLE scm= OpenSCManager(0, 0,SC_MANAGER_CREATE_SERVICE);
  if (! scm)
    return false;

  SC_HANDLE service= OpenService(scm, serviceName, DELETE);
  if (service)
  {
    if (DeleteService(service))
      ret_val= true;
    DWORD dw= ::GetLastError();
    CloseServiceHandle(service);
  }

  CloseServiceHandle(scm);
  return ret_val;
}
开发者ID:isleon,项目名称:Jaxer,代码行数:24,代码来源:WindowsService.cpp

示例15: uninstall_minifilter

int _cdecl uninstall_minifilter (void) {

	SC_HANDLE  hService = NULL;
	SC_HANDLE  hSCManager = NULL;
	int ret = 0;

	hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);

	PrintResult(L"OpenSCManager", L"Opening Service Control Manager Succeded");

	if(hSCManager) {
		if(!hService) {
			SERVICE_STATUS    ss;

			hService = OpenServiceW(hSCManager, L"protegeDados", SERVICE_START | DELETE | SERVICE_STOP);

			ControlService(hService, SERVICE_CONTROL_STOP, &ss);
			DeleteService(hService);
			ret = 1;
		}
		CloseServiceHandle(hSCManager);
	}
	return ret;
}
开发者ID:gfleury,项目名称:ProtegeDados_ProjetoFinal,代码行数:24,代码来源:service_install.c


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