Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7889217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:02:35+00:00 2026-06-03T06:02:35+00:00

I am trying to write a c/c++ application that start/stop any windows service of

  • 0

I am trying to write a c/c++ application that start/stop any windows service of my system.

My application is working fine for services that have no spaces in between their name, but for service names that have space between them are not responding.

Following are the commands i am using for opening service:

SC_HANDLE serviceDbHandle = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
SC_HANDLE serviceHandle = OpenService(serviceDbHandle,
                                      "My Service",
                                      SC_MANAGER_ALL_ACCESS);

Here "My Service" – 2nd parameter is LPCSTR and its null termination is creating problem.

How can i start/stop services that have spaces in their name – any clue or suggestions would be helpful.

Iam using Visual studio 2005 in xp machine.

Thanks,

Anil

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:02:37+00:00Added an answer on June 3, 2026 at 6:02 am

    You need to use the service’s internal name (which has no spaces), not the display name (which may).

    From MSDN:

    The name of the service to be opened. This is the name specified by the lpServiceName parameter of the CreateService function when the service object was created, not the service display name that is shown by user interface applications to identify the service.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a simple application that runs on a Windows Mobile
I'm trying to write a small Windows Service in .NET 3.5, that check every
I'm trying to write an application that will allow the user to start long-running
I'm trying to write an application that responds whenever the Shift key is pressed,
I am trying to write an application that performs operations on a grid of
I am trying to write an application that adds data to an exsiting spreadsheet
Hi I am trying to write an application that will play morse code. I
I'm trying to write an application (winforms) that can demonstrate how two oscillating colors
I'm trying to write a javascript application that loads data from the openstreetmap API
I'm trying to write a silverlight application that takes in InitParams and then uses

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.