public void SetSidType(ServiceSidType sidType) { var serviceSidInfo = new SERVICE_SID_INFO { ServiceSidType = sidType }; if (ChangeServiceConfig2WithServiceSidInfo(ServiceHandle, ServiceConfig2InfoLevel.SERVICE_CONFIG_SERVICE_SID_INFO, ref serviceSidInfo) == 0) { throw new System.ComponentModel.Win32Exception("Unable to set service SID type"); } }
static extern int ChangeServiceConfig2WithServiceSidInfo( System.IntPtr hService, ServiceConfig2InfoLevel dwInfoLevel, ref SERVICE_SID_INFO lpInfo);