1)怎样判断本机上某个iis站点是启动还是停止的?
2)用Delphi怎么控制IIS某个站点的启动和停止?
2)用Delphi怎么控制IIS某个站点的启动和停止?
解决方案 »
- fastreport一个很怪异的问题
- 怎样设置AdvEdit的Label颜色呢?
- 在Delphi中用ADO连接Excel的问题
- 问一个比较菜的问题,怎样在界面上加一个图片??
- delphi 中写SQL语句是如何用好分号?
- 请问高手应该怎样做?
- 求具有像word一样编辑功能的控件
- 关于dll中的Report棘手问题,高手请进来拿分。
- 高分求解刷新小问题 高手请入内!!!!!!!!!!!!!!!!!!!!!
- 开发分布式数据库系统,只用dcom不用mts可以吗?若可以,如何控制事务?
- 急切求救!! 磁卡编程 (没有接口函数,直接用Spcomm编程)!
- 如何Postmessage给DLL里面的一个form?
我认为判断一个服务是否运行
1。看看其是否存在于服务列表中
2。若存在,返回其当前状态。给你提供几个API参考...............
OpenSCManager
QueryServiceStatus
EnumServicesStatus
ChangeServiceConfig
SetServiceStatus
DWORD StartSampleService()
{
SERVICE_STATUS ssStatus;
DWORD dwOldCheckPoint;
DWORD dwStartTickCount;
DWORD dwWaitTime;
DWORD dwStatus;
schService = OpenService(
schSCManager, // SCM database
"Sample_Srv", // service name
SERVICE_ALL_ACCESS);
if (schService == NULL)
{
MyErrorExit("OpenService");
}
if (!StartService(
schService, // handle to service
0, // number of arguments
NULL) ) // no arguments
{
MyErrorExit("StartService");
}
else
{
printf("Service start pending.\n");
}
// Check the status until the service is no longer start pending.
if (!QueryServiceStatus(
schService, // handle to service
&ssStatus) ) // address of status information structure
{
MyErrorExit("QueryServiceStatus");
}
// Save the tick count and initial checkpoint. dwStartTickCount = GetTickCount();
dwOldCheckPoint = ssStatus.dwCheckPoint; while (ssStatus.dwCurrentState == SERVICE_START_PENDING)
{
// Do not wait longer than the wait hint. A good interval is
// one tenth the wait hint, but no less than 1 second and no
// more than 10 seconds.
dwWaitTime = ssStatus.dwWaitHint / 10; if( dwWaitTime < 1000 )
dwWaitTime = 1000;
else if ( dwWaitTime > 10000 )
dwWaitTime = 10000; Sleep( dwWaitTime ); // Check the status again.
if (!QueryServiceStatus(
schService, // handle to service
&ssStatus) ) // address of structure
break;
if ( ssStatus.dwCheckPoint > dwOldCheckPoint )
{
// The service is making progress. dwStartTickCount = GetTickCount():
dwOldCheckPoint = ssStatus.dwCheckPoint;
}
else
{
if(GetTickCount()-dwStartTickCount > ssStatus.dwWaitHint)
{
// No progress made within the wait hint
break;
}
}
} if (ssStatus.dwCurrentState == SERVICE_RUNNING)
{
printf("StartService SUCCESS.\n");
dwStatus = NO_ERROR;
}
else
{
printf("\nService not started. \n");
printf(" Current State: %d\n", ssStatus.dwCurrentState);
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);
dwStatus = GetLastError();
}
CloseServiceHandle(schService);
return dwStatus;
}