17,740
社区成员
发帖
与我相关
我的任务
分享
IntPtr entry = Marshal.AllocHGlobal((IntPtr) ((services.Length + 1) * Marshal.SizeOf(typeof(NativeMethods.SERVICE_TABLE_ENTRY))));
NativeMethods.SERVICE_TABLE_ENTRY[] service_table_entryArray = new NativeMethods.SERVICE_TABLE_ENTRY[services.Length];
bool multipleServices = services.Length > 1;
IntPtr zero = IntPtr.Zero;
for (int i = 0; i < services.Length; i++)
{
services[i].Initialize(multipleServices);
service_table_entryArray[i] = services[i].GetEntry();
zero = (IntPtr) (((long) entry) + (Marshal.SizeOf(typeof(NativeMethods.SERVICE_TABLE_ENTRY)) * i));
Marshal.StructureToPtr(service_table_entryArray[i], zero, true);
}
NativeMethods.SERVICE_TABLE_ENTRY structure = new NativeMethods.SERVICE_TABLE_ENTRY();
structure.callback = null;
structure.name = IntPtr.Zero;
zero = (IntPtr) (((long) entry) + (Marshal.SizeOf(typeof(NativeMethods.SERVICE_TABLE_ENTRY)) * services.Length));
Marshal.StructureToPtr(structure, zero, true);
bool flag2 = NativeMethods.StartServiceCtrlDispatcher(entry);