openservice ERROR_ACCESS_DENIED

Today, my colleague wrote a program to get the Window service with Sigar, and found that several services could not get out anyway.
I looked at the code and got it using OpenService, so I wrote a Demo using VC, but I still couldn’t get it.
But the error code is this 5, check MSDN is access problem.
 
Take a look at the permission bits obtained by Sigar, compare MSDN, Sigar USES ALL_ACCESS, but in Windows Scardspace, how to report an error.
http://www.cpp-home.com/forum/viewtopic.php?f=1& t=16325
http://social.msdn.microsoft.com/forums/en-US/vclanguage/thread/8c28faac-9056-4e72-9839-1f475079adc4
http://msdn.microsoft.com/en-us/library/windows/desktop/bb540474(v=vs.85).aspx
http://bbs.pediy.com/showthread.php?t=115649
 
After searching a few articles, the question was not completely solved, but fortunately we just want to get the status, not start and stop service, so we changed the source code, add a read permission bit (see MSDN), so
Even the bypass solves the problem.  
 

Read More: