Use this:
AM just hardcoded and comparing whether internet.exe is running!
like this you do it dynamically to determing any service running. also you may hav arguments passed from command line.
#include "afxwin.h"
# include <wtsapi32.h>
# include <iostream>
#pragma comment(lib,"wtsapi32.lib")
using namespace std;
DWORD pCount = 0;
PWTS_PROCESS_INFO ppProcessInfo,pProcess;
WTSEnumerateProcesses(WTS_CURRENT_SERVER_HANDLE,0,1,&ppProcessInfo,&pCount);
pProcess = ppProcessInfo;
CString internet = "iexplore.exe";
for(int i = 0; i < pCount; i++)
{
pProcess->pProcessName;
if (internet.CompareNoCase ( pProcess->pProcessName) == 0)
{
cout<< "iexplore running";
}
pProcess++;
}</iostream></wtsapi32.h>