如何停止、启动Win2000自带的一些服务,如传真服务等?

mynameisno1 2003-09-15 02:37:08
请高手们指点指点
给点儿资料什么的
...全文
32 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
mynameisno1 2003-09-25
  • 打赏
  • 举报
回复
masterz老兄已经走了吧,我想他老人家一定知道
mynameisno1 2003-09-24
  • 打赏
  • 举报
回复
谢谢
我现在想知道如何获得系统中所有服务的名称列表
masterz 2003-09-15
  • 打赏
  • 举报
回复
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/sending_control_requests_to_a_service.asp

Sending Control Requests to a Service
The following example uses the ControlService function to send a control value to a running service. Different control values require different levels of access to the service object. For example, a service object handle must have SERVICE_STOP access to send the SERVICE_CONTROL_STOP control code. When ControlService returns, a SERVICE_STATUS structure contains the latest status information for the service.


VOID ControlSampleService(DWORD fdwControl)
{
SERVICE_STATUS ssStatus;
DWORD fdwAccess;
DWORD dwStartTickCount, dwWaitTime;

// The required service object access depends on the control.

switch (fdwControl)
{
case SERVICE_CONTROL_STOP:
fdwAccess = SERVICE_STOP;
break;

case SERVICE_CONTROL_PAUSE:
case SERVICE_CONTROL_CONTINUE:
fdwAccess = SERVICE_PAUSE_CONTINUE;
break;

case SERVICE_CONTROL_INTERROGATE:
fdwAccess = SERVICE_INTERROGATE;
break;

default:
fdwAccess = SERVICE_INTERROGATE;
}

// Open a handle to the service.

schService = OpenService(
schSCManager, // SCManager database
"Sample_Srv", // name of service
fdwAccess); // specify access
if (schService == NULL)
MyErrorExit("OpenService");

// Send a control value to the service.

if (! ControlService(
schService, // handle to service
fdwControl, // control value to send
&ssStatus) ) // address of status info
{
MyErrorExit("ControlService");
}

// Print the service status.

printf("\nStatus of Sample_Srv: \n");
printf(" Service Type: 0x%x\n", ssStatus.dwServiceType);
printf(" Current State: 0x%x\n", ssStatus.dwCurrentState);
printf(" Controls Accepted: 0x%x\n",
ssStatus.dwControlsAccepted);
printf(" Exit Code: %d\n", ssStatus.dwWin32ExitCode);
printf(" Service Specific Exit Code: %d\n",
ssStatus.dwServiceSpecificExitCode);
printf(" Check Point: %d\n", ssStatus.dwCheckPoint);
printf(" Wait Hint: %d\n", ssStatus.dwWaitHint);

return;
}

2,640

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 硬件/系统
社区管理员
  • 硬件/系统社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧