Click here to Skip to main content
15,908,626 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionhow to realize scrolling text? Pin
xinyue5438-Jun-09 19:39
xinyue5438-Jun-09 19:39 
AnswerRe: how to realize scrolling text? Pin
Chandrasekharan P8-Jun-09 19:51
Chandrasekharan P8-Jun-09 19:51 
QuestionCWaitCursor changes back to normal cursor on mouse move event Pin
ptr_Electron8-Jun-09 19:33
ptr_Electron8-Jun-09 19:33 
AnswerRe: CWaitCursor changes back to normal cursor on mouse move event Pin
Chandrasekharan P8-Jun-09 19:48
Chandrasekharan P8-Jun-09 19:48 
GeneralRe: CWaitCursor changes back to normal cursor on mouse move event Pin
ptr_Electron8-Jun-09 22:59
ptr_Electron8-Jun-09 22:59 
AnswerRe: CWaitCursor changes back to normal cursor on mouse move event Pin
Nibu babu thomas8-Jun-09 20:17
Nibu babu thomas8-Jun-09 20:17 
AnswerRe: CWaitCursor changes back to normal cursor on mouse move event Pin
David Crow9-Jun-09 3:35
David Crow9-Jun-09 3:35 
QuestionHex string stream to Binary string Pin
RS.Ratheesh8-Jun-09 19:26
RS.Ratheesh8-Jun-09 19:26 
QuestionRe: Hex string stream to Binary string [modified] Pin
CPallini8-Jun-09 21:26
mveCPallini8-Jun-09 21:26 
AnswerRe: Hex string stream to Binary string Pin
RS.Ratheesh8-Jun-09 22:32
RS.Ratheesh8-Jun-09 22:32 
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 
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 
here is error from windows. it says "new01" has stopped working

Problem signature:
  Problem Event Name:	APPCRASH
  Application Name:	new01.exe
  Application Version:	0.0.0.0
  Application Timestamp:	4a349ab0
  Fault Module Name:	RPCRT4.dll
  Fault Module Version:	6.1.7100.0
  Fault Module Timestamp:	49eea681
  Exception Code:	c0000005
  Exception Offset:	0002f3b0
  OS Version:	6.1.7100.2.0.0.256.1
  Locale ID:	16393
  Additional Information 1:	0a9e
  Additional Information 2:	0a9e372d3b4ad19135b953a78882e789
  Additional Information 3:	0a9e
  Additional Information 4:	0a9e372d3b4ad19135b953a78882e789

Read our privacy statement online:
  http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
  C:\Windows\system32\en-US\erofflps.txt


here is the complete code of the program ----

// setting unicode

#ifndef UNICODE
#define UNICODE
#endif

// header files
#include <stdio.h>
#include <assert.h>
#include <windows.h>
#include <lm.h>
#include <tchar.h>
#include <wchar.h>



void printServer(LPSERVER_INFO_101 ppTmpBuf, DWORD ddwEntriesRead)
{
    SC_HANDLE hSCM;
    SERVICE_STATUS ss;
    DWORD i;
    short int j, x;
    x = 2;
    wchar_t* prName[] = { 
                        
                        _T("W3SVC"), 
                        _T("Themes")
                        
                        };

    for (i = 0; i < ddwEntriesRead; i++) 
    {
        for(j=0; j<x ; j++)
        {
            hSCM = OpenSCManager((LPCTSTR) ppTmpBuf->sv101_name,
                NULL, SC_MANAGER_CONNECT);
            if (hSCM != NULL)
            {
                SC_HANDLE hService = OpenService(hSCM, prName[j], SERVICE_QUERY_STATUS);
                if (hService != NULL)
                {                   
                    if (QueryServiceStatus(hService, &ss) != FALSE)
                    {
                        if ((ss.dwCurrentState == SERVICE_RUNNING)||(ss.dwCurrentState == SERVICE_START_PENDING))
                            wprintf(_T("%-20s %-15s This service is running.\n"),ppTmpBuf->sv101_name, prName[j]);
                        else 
                            wprintf(_T("%-20s %-15s This service is stopped or not found.\n"),ppTmpBuf->sv101_name, prName[j]); 
                    }
                    CloseServiceHandle(hService);
                }              
            }
             CloseServiceHandle(hSCM);
        }
        ppTmpBuf++;
    }
    NetApiBufferFree(ppTmpBuf);
}





void debugeFunct(NET_API_STATUS nState, LPSERVER_INFO_101 pTmpBuf, 
                 DWORD dwEntriesRead, DWORD dwTotalEntries)
{
    NET_API_STATUS nas ;
    NET_DISPLAY_MACHINE * pndm;
    DWORD dwNdmCount;
    
    switch(nState)
    {
    case NERR_Success:
    case ERROR_MORE_DATA:
        {
            if(pTmpBuf == NULL)
            {
                fprintf(stderr, "An access voilation has occurred.\n");
            }

            else
            {
                nas = NetQueryDisplayInformation (pTmpBuf->sv101_name,
                                                       2,
                                                       0,
                                                       1,
                                                       sizeof(NET_DISPLAY_MACHINE),
                                                       &dwNdmCount,
                                                       (PVOID*)&pndm);
                switch (nas)
                {                    
                case NERR_Success:
                case ERROR_MORE_DATA:
                    printServer(pTmpBuf, dwEntriesRead);
                    break;
                
                default:
                    {
                       printf("NQDI gave error %u\n", nas);
                       break;
                     }
                }
            }
        }
        break;

    default:
        printf("No pc were found. The buffer returned was NULL\n");
        break;


    }
    NetApiBufferFree(pTmpBuf);
}


void findServ(DWORD dwPrefMaxLen, DWORD dwServerType)
{
    LPSERVER_INFO_101 pBuf = NULL;
    DWORD dwLevel = 101;
    DWORD dwEntriesRead = 0;
    DWORD dwTotalEntries = 0;
    DWORD dwTotalCount = 0;
    DWORD dwResumeHandle = 0;
    NET_API_STATUS nStatus;
    LPTSTR pszServerName = NULL;
    LPTSTR pszDomainName = NULL;
 

 
    nStatus = NetServerEnum(
                            (LPCWSTR) pszServerName,
                            dwLevel,
                            (LPBYTE *) & pBuf,
                            dwPrefMaxLen,
                            &dwEntriesRead,
                            &dwTotalEntries,
                            dwServerType, 
                            (LPCWSTR) pszDomainName, 
                            &dwResumeHandle
                            );
    
    
    debugeFunct(nStatus, pBuf, dwEntriesRead, dwTotalEntries);
    NetApiBufferFree(pBuf);

}

     
  
int _tmain(int argc, wchar_t * argv[])
{
    DWORD dPrefMaxLen = MAX_PREFERRED_LENGTH;
    DWORD dServerType = SV_TYPE_SERVER;
    printf("Machine              Service         Status\n");
    while(1)
    {
    findServ(dPrefMaxLen, dServerType);
    Sleep(3000);
    }
    return 0;
}
Here is the event viewer file of the application

modified on Sunday, June 14, 2009 10:33 AM

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 

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.