/// <summary> /// Sets (add or overwrite) the content of a specific profile. /// </summary> /// <param name="interfaceId">Interface ID</param> /// <param name="profileType">Profile type</param> /// <param name="profileXml">Profile XML</param> /// <param name="profileSecurity">Security descriptor for all-user profile</param> /// <param name="overwrite">Whether to overwrite an existing profile</param> /// <returns>True if successfully set. False if not.</returns> /// <remarks> /// If the content of the profile XML is not valid, a Win32Exception will be thrown. /// In such case, check the reason code in the message and see /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms707394.aspx /// https://technet.microsoft.com/en-us/library/3ed3d027-5ae8-4cb0-ade5-0a7c446cd4f7#BKMK_AppndxE /// </remarks> public static bool SetProfile(Guid interfaceId, ProfileType profileType, string profileXml, string profileSecurity, bool overwrite) { if (interfaceId == Guid.Empty) { throw new ArgumentException(nameof(interfaceId)); } if (string.IsNullOrWhiteSpace(profileXml)) { throw new ArgumentNullException(nameof(profileXml)); } using (var client = new Base.WlanClient()) { return(Base.SetProfile(client.Handle, interfaceId, profileType, profileXml, profileSecurity, overwrite)); } }