I want to p/invoke the windows api function ChangeServiceConfig2 for setting the description and/or "start delayed" flag for a service (and possibly more). Special thing about this is that it takes a pointer to different structures depending on what you want to change.
For example, to change the description text of a service, you'll need to point it to a SERVICE_DESCRIPTION structure and to change the delayed flag you'll point to a SERVICE_DELAYED_AUTO_START_INFO structure.
I have solved this by creating several overloads of the api function like this:
private static extern bool ChangeServiceConfig2(IntPtr hService, int dwInfoLevel, [MarshalAs(UnmanagedType.Struct)] ref SERVICE_DESCRIPTION lpInfo);
private static extern bool ChangeServiceConfig2(IntPtr hService, int dwInfoLevel, [MarshalAs(UnmanagedType.Struct)] ref SERVICE_DELAYED_AUTO_START_INFO lpInfo);
I want to ask if there's a better solution that wouldn't require another dozen or so overloads if I want to completely prototype it?