• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 581
  • Last Modified:

EnumServicesStatus - Usage?

Hi folks,

can anyone help with this code:

- i can get access to the services database, strat and stop services etc, but can't figure out how i am supposed to use this EnumServicesStatus function!!


LPCTSTR servername;
SERVICE_STATUS service_status;
LPCSTR servicename;

char outputbuffer[128];

servername = strdup("server");

sprintf(outputbuffer, "Unspecified Error");

SC_HANDLE server_handle = OpenSCManager(

      ENUM_SERVICE_STATUS *service_status = (ENUM_SERVICE_STATUS *)malloc(65535);
      DWORD bytesneeded;
      DWORD numberreturned;
      DWORD resumehandle;
      DWORD services_buffersize = 65535;

            sprintf(outputbuffer, "got %d services, need %d bytes, resumehandle = %d", numberreturned, bytesneeded, resumehandle);
            sprintf(outputbuffer, "Failed to list services");
            returncode = 60;
else sprintf(outputbuffer, "Faled to get server handle");

  • 2
  • 2
1 Solution
Look into the sample code provided with the following articles.

NT Simple Service Manager

WindowsNT Simple Service Manager (2)
meverestAuthor Commented:
thanks for the blindingly fast response.

as it turns out, i came back here to remove the question as i figured it out by myself (read the docs man! ;-)

the answer was that resumehandle MUST be set to zero for the first call, did that and it worked just like it's sposed to! :)

anyway, i accept your answer not so much for the content (which i didn't have to look at), but for the quick reply! ;-)

I have to say that your question is very vague. You didn't tell us what error you got or what you didn't understand. You just told us that you did not know how to use the function. So, I gave you complete samples. Ask a complete and clear question next time. By the way, this question should have been posted to the Windows programming topic area. It has nothing to do with C++ language.
meverestAuthor Commented:
and i thank you for that! :)

and thanks for the tip too - i will post in that group next time i have a similar question.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now