Solved

service name

Posted on 2001-07-22
5
245 Views
Last Modified: 2010-04-06
Hi,
im installing a service and would like to call servicestart() straight after but cant see how without knowing the service name first to pass to it..
i have one solution but i wonder if anyone knows better way.
my solution was :

after installing i can get a list of services from the registry
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services
and search each subkey for the "ImagePath" item that contains the exe name and then if the imagepath contains the exe name i know the subkey is the name of the service

any other ideas?
0
Comment
Question by:inthe
  • 3
  • 2
5 Comments
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6307146
EnumServicesStatus?
0
 
LVL 17

Author Comment

by:inthe
ID: 6307331
Hi,
EnumServicesStatus does just that ,
gets the status of a service ..i could do with a EnumServices() or a
GetServiceNameFromFile(filename:string);
 function :-)
0
 
LVL 14

Accepted Solution

by:
DragonSlayer earned 100 total points
ID: 6307584
Hi inthe, :)

EnumServicesStatus enumerates through all services, returning an array of ENUM_SERVICE_STATUS

Just loop through the ENUM_SERVICE_STATUS structure, for the structure contains 3 fields, the ServiceName, DisplayName and the ServiceStatus.


DragonSlayer.
0
 
LVL 17

Author Comment

by:inthe
ID: 6309826
Hi,
ok so im blind and stupid ;-)
the example i had of EnumServicesStatus was not coded right that why it returned only one service,it was also looking for SERVICE_STOPPED instead of SERVICE_INACTIVE.
took a while to get it working correct but now its working,just need to add the compare code to test for service name.

ps,
sorry for delay ,i got confused when looking on newsgroups for examples as there were so many that do not work,or worse some do work but only return 30 or so services when it shouldve returned 60 like it is now.

thanks for showng right path to take anyways :-)

Regards Barry
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6310666
No probs... that's what ExpertsExchange is for, rite? To "open each others' eyes"  :)


DragonSlayer
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question