private void GenerateNames() { if (this.machineName.Length == 0) { throw new ArgumentException(Res.GetString("NoMachineName")); } this.GetDataBaseHandleWithConnectAccess(); if (this.name.Length == 0) { string eitherName = this.eitherName; if (eitherName.Length == 0) { eitherName = this.displayName; } if (eitherName.Length == 0) { throw new InvalidOperationException(Res.GetString("NoGivenName")); } int capacity = 0x100; StringBuilder shortName = new StringBuilder(capacity); if (!SafeNativeMethods.GetServiceKeyName(this.serviceManagerHandle, eitherName, shortName, ref capacity)) { bool flag = SafeNativeMethods.GetServiceDisplayName(this.serviceManagerHandle, eitherName, shortName, ref capacity); if (!flag && (capacity >= 0x100)) { shortName = new StringBuilder(++capacity); flag = SafeNativeMethods.GetServiceDisplayName(this.serviceManagerHandle, eitherName, shortName, ref capacity); } if (!flag) { Exception innerException = CreateSafeWin32Exception(); throw new InvalidOperationException(Res.GetString("NoService", new object[] { eitherName, this.machineName }), innerException); } this.name = eitherName; this.displayName = shortName.ToString(); this.eitherName = ""; } else { this.name = shortName.ToString(); this.displayName = eitherName; this.eitherName = ""; } } if (this.displayName.Length == 0) { int num2 = 0x100; StringBuilder displayName = new StringBuilder(num2); bool flag2 = SafeNativeMethods.GetServiceDisplayName(this.serviceManagerHandle, this.name, displayName, ref num2); if (!flag2 && (num2 >= 0x100)) { displayName = new StringBuilder(++num2); flag2 = SafeNativeMethods.GetServiceDisplayName(this.serviceManagerHandle, this.name, displayName, ref num2); } if (!flag2) { Exception exception2 = CreateSafeWin32Exception(); throw new InvalidOperationException(Res.GetString("NoDisplayName", new object[] { this.name, this.machineName }), exception2); } this.displayName = displayName.ToString(); } }