请问怎么实现关闭系统服务!!!!!!!!!!(在线等!!!

rock7up 2004-08-04 10:31:51
本人想编辑一个小软件,功能实现关闭不需要的系统服务
比如,办公情况下(不含有打印),就不需要网络的连接,所以,关于打印和网络的服务都关闭!!!!!
我知道很多的服务都是通过svchost.exe来调用启动的,但是,不知道怎么来实现 ,大概的思路就是这样的了,各位朋友帮我想想!!!!!!!!
...全文
151 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ccrun.com 2004-12-10
  • 打赏
  • 举报
回复
汗。。。
powerants 2004-12-10
  • 打赏
  • 举报
回复
學而時习之,不亦樂乎?
ccrun.com 2004-12-08
  • 打赏
  • 举报
回复
这么久的帖子了。who给翻出来的。楼主还不结帐啊。
powerants 2004-12-08
  • 打赏
  • 举报
回复
那麼怎麼樣來啟動他呢?
  • 打赏
  • 举报
回复
这么久的帖子了。who给翻出来的。楼主还不结帐啊。 还有谁啊
回复人: powerants(西门铸剑) ( ) 信誉:100 2004-12-08 11:58:00 得分: 0
captainivy 2004-08-06
  • 打赏
  • 举报
回复
请问怎样禁用一项系统服务呢?



constantine 2004-08-04
  • 打赏
  • 举报
回复
老妖这方面很强,我来学习了
ccrun.com 2004-08-04
  • 打赏
  • 举报
回复
晕.怎么多出个a来?

if(MyStopService("", "Messenger"))a
ShowMessage("搞定!");

把那个最后的a去掉就可以了.
ccrun.com 2004-08-04
  • 打赏
  • 举报
回复
// 停止指定机器上的指定服务
// strMachine: 机器名,如指定本机,则留空
// strService: 服务名.
bool MyStopService(String strMachine, String strService)
{
// service control manager handle and service handle
SC_HANDLE schm, schs;
// service status
SERVICE_STATUS SrvStatus;
// check point
DWORD dwChkPoint;

// connect to the service control manager
schm = OpenSCManager(strMachine.c_str(), NULL, SC_MANAGER_CONNECT);
if(schm > 0)
{
// open a handle to the specified service
// we want to stop the service and query service status
schs = OpenService(schm, strService.c_str(), SERVICE_STOP | SERVICE_QUERY_STATUS);
if(schs > 0)
{
if(ControlService(schs, SERVICE_CONTROL_STOP, &SrvStatus))
{
// check status
if(QueryServiceStatus(schs, &SrvStatus))
{
while(SERVICE_STOPPED != SrvStatus.dwCurrentState)
{
// dwCheckPoint contains a value that the service
// increments periodically to report its progress
// during a lengthy operation.
// save current value
dwChkPoint = SrvStatus.dwCheckPoint;
// wait a bit before checking status again
// dwWaitHint is the estimated amount of time
// the calling program should wait before calling
// QueryServiceStatus() again
// idle events should be handled here...
Sleep(SrvStatus.dwWaitHint);
if(!QueryServiceStatus(schs, &SrvStatus))
// couldn't check status break from the loop
break;
if(SrvStatus.dwCheckPoint < dwChkPoint)
// QueryServiceStatus didn't increment
// dwCheckPoint as it should have.
// avoid an infinite loop by breaking
break;
}
}
}
} // end of if(schs > 0)
// close service handle
CloseServiceHandle(schs);
}
// close service control manager handle
CloseServiceHandle(schm);
// return TRUE if the service status is stopped
return (SERVICE_STOPPED == SrvStatus.dwCurrentState);
}
//---------------------------------------------------------------------------
// 调用举例: 停止本机的信使服务.
// 在停止服务时需要等待一段时间,可以自己添加一个类似Win2k中的停止服务时的进度条.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(MyStopService("", "Messenger"))a
ShowMessage("搞定!");
}
//---------------------------------------------------------------------------

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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