TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mike Smith
NA
5
0
Using return true and false
Nov 3 2017 10:20 AM
Hello,
I'm not very familar with using return true and false.
I found this code and would like to understand how to best use it.
public static bool IsServiceInstalled(string serviceName)
{
// get list of Windows services
ServiceController[] services = ServiceController.GetServices();
// try to find service name
foreach (ServiceController service in services)
{
if (service.ServiceName == "ServiceNameHere")
return true;
MessageBox.Show("true");
}
return false;
}
So, can someone show me a simple example of using this on say a form load.
Here is what I came up with so far.
ServiceController[] services = ServiceController.GetServices();
If (services == "ServiceName"
{
MessageBox.Show("Service: Found");
}
else
{
MessageBox.Show("Service: Not Found");
}
Thanks for the help!
Reply
Answers (
1
)
C# searching a Access Database
Treeview filled dynamically from 5 tables in C# windows form