Click here to Skip to main content
15,887,776 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Hex string stream to Binary string Pin
David Crow9-Jun-09 3:38
David Crow9-Jun-09 3:38 
Question[help]detect the status of iis server Pin
rahuljin8-Jun-09 18:59
rahuljin8-Jun-09 18:59 
QuestionRe: [help]detect the status of iis server Pin
David Crow9-Jun-09 3:39
David Crow9-Jun-09 3:39 
AnswerRe: [help]detect the status of iis server Pin
rahuljin9-Jun-09 8:50
rahuljin9-Jun-09 8:50 
GeneralRe: [help]detect the status of iis server Pin
David Crow9-Jun-09 9:23
David Crow9-Jun-09 9:23 
GeneralRe: [help]detect the status of iis server Pin
rahuljin9-Jun-09 10:38
rahuljin9-Jun-09 10:38 
GeneralRe: [help]detect the status of iis server Pin
David Crow10-Jun-09 3:43
David Crow10-Jun-09 3:43 
GeneralRe: [help]detect the status of iis server Pin
rahuljin12-Jun-09 1:46
rahuljin12-Jun-09 1:46 
thanks for the link. i have tried to write some code but it is not working. can u find the mistake i am making ? i want to find the status of the service "W3SVC", and when it is running, the program should print "Found" ----

<br />
<br />
#ifndef UNICODE<br />
#define UNICODE<br />
#endif<br />
<br />
#include <stdio.h><br />
#include <assert.h><br />
#include <windows.h><br />
#include <lm.h><br />
#include <tchar.h><br />
#include <wchar.h><br />
<br />
int wmain(int argc, wchar_t * argv[])<br />
{<br />
    LPSERVER_INFO_101 pBuf = NULL;<br />
    LPSERVER_INFO_101 pTmpBuf;<br />
    DWORD dwLevel = 101;<br />
    DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH;<br />
    DWORD dwEntriesRead = 0;<br />
    DWORD dwTotalEntries = 0;<br />
    DWORD dwTotalCount = 0;<br />
    DWORD dwServerType = SV_TYPE_SERVER;        // all servers<br />
    DWORD dwResumeHandle = 0;<br />
    NET_API_STATUS nStatus;<br />
    LPTSTR pszServerName = NULL;<br />
    LPTSTR pszDomainName = NULL;<br />
    DWORD i;<br />
<br />
    if (argc > 2) <br />
	{<br />
        fwprintf(stderr, L"Usage: %s [DomainName]\n", argv[0]);<br />
        exit(1);<br />
    }<br />
    // The request is not for the primary domain.<br />
    //<br />
    if (argc == 2)<br />
        pszDomainName = argv[1];<br />
    //<br />
    // Call the NetServerEnum function to retrieve information<br />
    //  for all servers, specifying information level 101.<br />
    //<br />
    nStatus = NetServerEnum((LPCWSTR) pszServerName,<br />
                            dwLevel,<br />
                            (LPBYTE *) & pBuf,<br />
                            dwPrefMaxLen,<br />
                            &dwEntriesRead,<br />
                            &dwTotalEntries,<br />
                            dwServerType, <br />
                            (LPCWSTR) pszDomainName, <br />
                            &dwResumeHandle);<br />
    //<br />
    // If the call succeeds,<br />
    //<br />
    if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA)) {<br />
        if ((pTmpBuf = pBuf) != NULL) {<br />
            //<br />
            // Loop through the entries and <br />
            //  print the data for all server types.<br />
            //<br />
            for (i = 0; i < dwEntriesRead; i++) {<br />
                assert(pTmpBuf != NULL);<br />
<br />
                if (pTmpBuf == NULL) {<br />
                    fprintf(stderr, "An access violation has occurred\n");<br />
                    break;<br />
                }<br />
<br />
                printf("\tPlatform: %d\n", pTmpBuf->sv101_platform_id);<br />
                wprintf(L"\tName:     %s\n", pTmpBuf->sv101_name);<br />
                printf("\tVersion:  %d.%d\n",<br />
                       pTmpBuf->sv101_version_major,<br />
                       pTmpBuf->sv101_version_minor);<br />
                printf("\tType:     %d", pTmpBuf->sv101_type);<br />
                //<br />
                // Check to see if the server is a domain controller;<br />
                //  if so, identify it as a PDC or a BDC.<br />
                //<br />
                if (pTmpBuf->sv101_type & SV_TYPE_DOMAIN_CTRL)<br />
                    wprintf(L" (PDC)");<br />
                else if (pTmpBuf->sv101_type & SV_TYPE_DOMAIN_BAKCTRL)<br />
                    wprintf(L" (BDC)");<br />
<br />
                printf("\n");<br />
                SC_HANDLE hSCM = OpenSCManager((LPCTSTR) pTmpBuf->sv101_name, NULL, SC_MANAGER_CONNECT);<br />
<br />
                if (hSCM != NULL)<br />
                {<br />
                    SC_HANDLE hService = OpenService(hSCM, _T("W3SVC"), SERVICE_QUERY_STATUS);<br />
                    if (hService != NULL)<br />
                    {<br />
                      SERVICE_STATUS ss;<br />
                      if ((QueryServiceStatus(hService, &ss) == SERVICE_RUNNING)||(QueryServiceStatus(hService, &ss) == SERVICE_START_PENDING))<br />
                             printf("Found");<br />
<br />
                 CloseServiceHandle(hService);<br />
                }<br />
               CloseServiceHandle(hSCM);<br />
            }<br />
<br />
                // Also print the comment associated with the server.<br />
                //<br />
                wprintf(L"\tComment:  %s\n\n", pTmpBuf->sv101_comment);<br />
<br />
                pTmpBuf++;<br />
                dwTotalCount++;<br />
            }<br />
            // Display a warning if all available entries were<br />
            //  not enumerated, print the number actually <br />
            //  enumerated, and the total number available.<br />
<br />
            if (nStatus == ERROR_MORE_DATA) {<br />
                fprintf(stderr, "\nMore entries available!!!\n");<br />
                fprintf(stderr, "Total entries: %d", dwTotalEntries);<br />
            }<br />
<br />
            printf("\nEntries enumerated: %d\n", dwTotalCount);<br />
<br />
        } else {<br />
            printf("No servers were found\n");<br />
            printf("The buffer (bufptr) returned was NULL\n");<br />
            printf("  entriesread: %d\n", dwEntriesRead);<br />
            printf("  totalentries: %d\n", dwEntriesRead);<br />
        }<br />
<br />
    } else<br />
        fprintf(stderr, "NetServerEnum failed with error: %d\n", nStatus);<br />
    //<br />
    // Free the allocated buffer.<br />
    //<br />
    if (pBuf != NULL)<br />
        NetApiBufferFree(pBuf);<br />
<br />
    return 0;<br />
}<br />
<br />
<br />

GeneralRe: [help]detect the status of iis server Pin
David Crow12-Jun-09 3:06
David Crow12-Jun-09 3:06 
GeneralRe: [help]detect the status of iis server [modified] Pin
rahuljin12-Jun-09 4:35
rahuljin12-Jun-09 4:35 
QuestionRe: [help]detect the status of iis server Pin
David Crow13-Jun-09 12:41
David Crow13-Jun-09 12:41 
AnswerRe: [help]detect the status of iis server [modified] Pin
rahuljin13-Jun-09 20:42
rahuljin13-Jun-09 20:42 
QuestionRe: [help]detect the status of iis server Pin
David Crow14-Jun-09 10:03
David Crow14-Jun-09 10:03 
AnswerRe: [help]detect the status of iis server Pin
rahuljin14-Jun-09 11:19
rahuljin14-Jun-09 11:19 
AnswerRe: [help]detect the status of iis server Pin
David Crow15-Jun-09 3:57
David Crow15-Jun-09 3:57 
GeneralRe: [help]detect the status of iis server [modified] Pin
rahuljin15-Jun-09 5:26
rahuljin15-Jun-09 5:26 
QuestionHi! VC console GUI Pin
tuan11118-Jun-09 17:42
tuan11118-Jun-09 17:42 
AnswerRe: Hi! VC console GUI Pin
Chandrasekharan P8-Jun-09 18:08
Chandrasekharan P8-Jun-09 18:08 
AnswerRe: Hi! VC console GUI Pin
Cedric Moonen8-Jun-09 20:19
Cedric Moonen8-Jun-09 20:19 
AnswerRe: Hi! VC console GUI Pin
Michael Schubert9-Jun-09 0:44
Michael Schubert9-Jun-09 0:44 
QuestionHow to convert a VARIANT buffer to a byte buffer? Pin
gpenghe8-Jun-09 17:00
gpenghe8-Jun-09 17:00 
AnswerRe: How to convert a VARIANT buffer to a byte buffer? Pin
«_Superman_»8-Jun-09 19:23
professional«_Superman_»8-Jun-09 19:23 
GeneralRe: How to convert a VARIANT buffer to a byte buffer? Pin
gpenghe8-Jun-09 23:38
gpenghe8-Jun-09 23:38 
GeneralRe: How to convert a VARIANT buffer to a byte buffer? Pin
«_Superman_»9-Jun-09 5:33
professional«_Superman_»9-Jun-09 5:33 
GeneralRe: How to convert a VARIANT buffer to a byte buffer? Pin
gpenghe9-Jun-09 5:43
gpenghe9-Jun-09 5:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.