Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than advapi32, prefix the name with the module name and a period.
EnumDependentServices (advapi32)
.
C# Signature:
[DllImport("advapi32.dll", EntryPoint="EnumDependentServicesW", ExactSpelling=true, SetLastError=true)]
static extern bool EnumDependentServices( IntPtr hService,
SERVICE_STATES dwServiceState,
ref ENUM_SERVICE_STATUS lpServices,
int cbBufSize,
ref int pcbBytesNeeded,
ref int lpServicesReturned );
VB Signature:
Declare Function EnumDependentServices Lib "advapi32.dll" (TODO) As TODO
User-Defined Types:
None.
Notes:
None.
Tips & Tricks:
Please add some!
Sample Code:
IntPtr handle = OpenSCManager( null, null, SCM_ACCESS.SC_MANAGER_ALL_ACCESS );
if ( handle != IntPtr.Zero )
{
int iBytesNeeded = 0;
int iServicesReturned = 0;
int iResumeHandle = 0;
if ( !EnumServicesStatus( handle,
SERVICE_TYPES.SERVICE_WIN32,
SERVICE_STATES.SERVICE_STATE_ALL,
IntPtr.Zero,
0,
ref iBytesNeeded,
ref iServicesReturned,
ref iResumeHandle ) )
{
IntPtr buf = Marshal.AllocHGlobal( (int) iBytesNeeded );
if ( !EnumServicesStatus( handle,
SERVICE_TYPES.SERVICE_WIN32,
SERVICE_STATES.SERVICE_STATE_ALL,
buf,
iBytesNeeded,
ref iBytesNeeded,
ref iServicesReturned,
ref iResumeHandle ) )
{
Debug.WriteLine("EnumServicesStatus Failed " + Marshal.GetLastWin32Error() );
}
else
{
ENUM_SERVICE_STATUS serviceStatus;
int iPtr = buf.ToInt32();
for ( int i = 0 ; i < (int) iServicesReturned; i++ )
{
serviceStatus = (ENUM_SERVICE_STATUS) Marshal.PtrToStructure( new IntPtr(iPtr), typeof(ENUM_SERVICE_STATUS) );
Debug.WriteLine("Service " + serviceStatus.pServiceName );
Debug.Indent();
IntPtr hService = OpenService( handle, serviceStatus.pServiceName, SERVICE_ACCESS.SERVICE_ALL_ACCESS );
if ( hService != IntPtr.Zero )
{
int iDepBytesNeeded = 0;
int iDepServicesReturned = 0;
The EnumDependentServices function retrieves the name and status of each service that depends on the specified service; that is, the specified service must be running before the dependent services can run.
3/16/2007 7:31:59 AM - anfortas.geo@yahoo.com-216.204.61.86
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).