private static void SetOpCode(Nic nic, WlanInternOpcode opCode, int value, out int errorCode) { IntPtr valuePtr = Marshal.AllocHGlobal(sizeof (int)); Marshal.WriteInt32(valuePtr, value); try { errorCode = WlanInterop.SetInterface(_handle, Guid.Parse(nic.Raw.NetworkInterface.Id), opCode, sizeof (int), valuePtr, IntPtr.Zero); } finally { Marshal.FreeHGlobal(valuePtr); } }
private static int GetOpCode(Nic nic, WlanInternOpcode opCode, out int errorCode) { IntPtr valuePtr; int valueSize; WlanInternOpcodeValueType opcodeValueType; if ((errorCode = WlanInterop.QueryInterface(_handle, nic.Hardware.Id, opCode, IntPtr.Zero, out valueSize, out valuePtr, out opcodeValueType)) != 0) return 0; try { return Marshal.ReadInt32(valuePtr); } finally { WlanInterop.FreeMemory(valuePtr); } }
/// <summary>Gets a parameter of the interface whose data type is <see cref="int" />.</summary> internal static int TryGetOpCode(Nic nic, WlanInternOpcode opCode) { int error; var result = GetOpCode(nic, opCode, out error); return result; }
/// <summary>Sets a parameter of the interface whose data type is <see cref="int" />.</summary> internal static void TrySetOpCode(Nic nic, WlanInternOpcode opCode, int value) { int error; SetOpCode(nic, opCode, value, out error); }
/// <summary>Sets a parameter of the interface whose data type is <see cref="int" />.</summary> internal static void SetOpCode(Nic nic, WlanInternOpcode opCode, int value) { int error; SetOpCode(nic, opCode, value, out error); ThrowIfError(error); }