Click here to Skip to main content
15,886,919 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: About Thread argument Pin
CPallini14-Dec-07 1:09
mveCPallini14-Dec-07 1:09 
GeneralRe: About Thread argument Pin
Cedric Moonen14-Dec-07 1:15
Cedric Moonen14-Dec-07 1:15 
GeneralRe: About Thread argument Pin
CPallini14-Dec-07 2:43
mveCPallini14-Dec-07 2:43 
GeneralRe: About Thread argument Pin
Cedric Moonen14-Dec-07 1:12
Cedric Moonen14-Dec-07 1:12 
GeneralRe: About Thread argument Pin
CPallini14-Dec-07 2:50
mveCPallini14-Dec-07 2:50 
JokeRe: About Thread argument Pin
Cedric Moonen14-Dec-07 4:06
Cedric Moonen14-Dec-07 4:06 
GeneralRe: About Thread argument Pin
Member 75496014-Dec-07 9:08
Member 75496014-Dec-07 9:08 
Generalcheck if service is available - Vista Pin
Lord_Draconis13-Dec-07 22:17
Lord_Draconis13-Dec-07 22:17 
Hello,

Is there any way to check if service is available in scmanager from account that is different than the account the service is logging to??

I am using such code:
...
SC_HANDLE hHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE);

if (NULL == hHandle)
{
return FALSE;
}

ENUM_SERVICE_STATUS service;

DWORD dwBytesNeeded = 0;
DWORD dwServicesReturned = 0;
DWORD dwResumedHandle = 0;
DWORD dwServiceType = SERVICE_WIN32;

// Query services
BOOL retVal = EnumServicesStatus(hHandle, dwServiceType, SERVICE_STATE_ALL,
&service, sizeof(ENUM_SERVICE_STATUS), &dwBytesNeeded, &dwServicesReturned,
&dwResumedHandle);

if (!retVal) {
// Need big buffer

if (ERROR_MORE_DATA == GetLastError()) {
// Set the buffer

DWORD dwBytes = sizeof(ENUM_SERVICE_STATUS) + dwBytesNeeded;
ENUM_SERVICE_STATUS* pServices = NULL;
pServices = new ENUM_SERVICE_STATUS [dwBytes];

// Now query again for services
EnumServicesStatus(hHandle, SERVICE_WIN32,
SERVICE_STATE_ALL, pServices, dwBytes, &dwBytesNeeded,
&dwServicesReturned, &dwResumedHandle);

// now traverse each service to get information

for ( unsigned iIndex = 0; iIndex < dwServicesReturned; iIndex++ )
{
CString sServiceName = (pServices + iIndex)->lpServiceName;
if ( !sServiceName.Compare( "Net-SNMP Agent" ) )
{
return TRUE;
}
}
...

It seems to work on XP but not on Vista but I maybe wrong.

Many thanks,


Draco
GeneralRe: check if service is available - Vista Pin
JudyL_MD14-Dec-07 2:24
JudyL_MD14-Dec-07 2:24 
GeneralRe: check if service is available - Vista Pin
Lord_Draconis14-Dec-07 3:41
Lord_Draconis14-Dec-07 3:41 
GeneralRe: check if service is available - Vista Pin
JudyL_MD14-Dec-07 3:53
JudyL_MD14-Dec-07 3:53 
QuestionPrint Preview in Dialog Pin
Shivarudrayya H13-Dec-07 21:57
Shivarudrayya H13-Dec-07 21:57 
GeneralRe: Print Preview in Dialog Pin
Nelek13-Dec-07 22:38
protectorNelek13-Dec-07 22:38 
GeneralRe: Print Preview in Dialog Pin
Shivarudrayya H13-Dec-07 22:56
Shivarudrayya H13-Dec-07 22:56 
GeneralRe: Print Preview in Dialog Pin
Nelek13-Dec-07 23:57
protectorNelek13-Dec-07 23:57 
GeneralRe: Print Preview in Dialog Pin
santhoshv8413-Dec-07 22:39
santhoshv8413-Dec-07 22:39 
Generalc++ and ... Pin
mostafa_h13-Dec-07 21:49
mostafa_h13-Dec-07 21:49 
GeneralRe: c++ and ... Pin
Nelek13-Dec-07 22:27
protectorNelek13-Dec-07 22:27 
GeneralRe: c++ and ... Pin
mostafa_h13-Dec-07 23:15
mostafa_h13-Dec-07 23:15 
GeneralRe: c++ and ... Pin
toxcct13-Dec-07 23:40
toxcct13-Dec-07 23:40 
GeneralRe: c++ and ... [modified] Pin
Nelek14-Dec-07 0:09
protectorNelek14-Dec-07 0:09 
GeneralRe: c++ and ... Pin
toxcct14-Dec-07 0:40
toxcct14-Dec-07 0:40 
JokeRe: c++ and ... Pin
Nelek14-Dec-07 0:42
protectorNelek14-Dec-07 0:42 
GeneralRe: c++ and ... Pin
toxcct14-Dec-07 0:47
toxcct14-Dec-07 0:47 
GeneralRe: c++ and ... Pin
mostafa_h14-Dec-07 5:18
mostafa_h14-Dec-07 5:18 

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.