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
matt.schutz
NA
1
0
Windows Service Creation/Installation
Oct 19 2004 3:22 PM
I am using some code found here: http://www.c-sharpcorner.com/Code/2003/Sept/InstallingWinServiceProgrammatically.asp as a model to install a Windows service. This code seems to mix and match C++ with C# quite a bit. I am having problems with the point where I get to this section in the InstallService() method: if (sc_handle.ToInt32() != 0) { IntPtr sv_handle = CreateService(sc_handle,svcName,svcDispName,SERVICE_ALL_ACCESS,SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START,SERVICE_ERROR_NORMAL,svcPath,null,0,null,null,null); if(sv_handle.ToInt32() != 0 ) { CloseServiceHandle(sc_handle); return false; } else { //now trying to start the service int i = StartService(sv_handle,0,null); ... ... ... I have determined that the sv_handle.ToInt32() must be NOT EQUAL rather than EQUAL as orignially posted in the code in the link above due to return codes given by CreateService(). I get inside the sc_handle.ToInt32() != 0 block just fine. Then the sv_handle.ToInt32() != 0 fails. sv_handle.ToInt32() IS equal to zero. My question is, why require sv_handle to be equal to zero, then use that (a zero value) as the handle to try to start the service? I can't quite figure this one out. Anyone have any ideas? Much appreciated.
Reply
Answers (
0
)
Help Needed with Windows Programming
Help with xml path and selectNodes