1)怎样判断本机上某个iis站点是启动还是停止的?
2)用Delphi怎么控制IIS某个站点的启动和停止?

解决方案 »

  1.   

    呵呵,翻一下WIN2000API,里边有提供这种API
      

  2.   

    WinSvc单元。
    我认为判断一个服务是否运行
    1。看看其是否存在于服务列表中
    2。若存在,返回其当前状态。给你提供几个API参考...............
    OpenSCManager
    QueryServiceStatus
    EnumServicesStatus
    ChangeServiceConfig
    SetServiceStatus
      

  3.   

    我不是说IIS服务,而是说IIS建立的某个站点是否启动!拜托!!!各位!!!
      

  4.   

    仅供参考了:
    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;

      

  5.   

    我不是说IIS服务,而是说IIS建立的某个站点是否启动!拜托!!!各位!!!搞清楚问题在上帖子。我不是想知道IIS服务是否启动,而是想知道IIS服务上的某个站点是否启动。
      

  6.   

    Win2000 server有两个方面:ADSI和Metabase,Win2003 server还可以通过WMI来控制,我只做过ADSI和MetaBase来控制IIS站点,包括开设虚拟主机(站点)。相对来说ADSI比较容易,它只是对W3SVC(inetinfo) 的COM操作,MetaBase比较难,当MetaBase稳定性非常好,成功率99.9%,ADSI是通过COM的,稳定性相对与InetInfo.
      

  7.   

    启动与停止站点只要站点Identifier为1012的Data(值)也就是Server Command,为1是启动,为2是停止。