Example #1
0
        /// <summary>
        /// Gets a parameter of the interface whose data type is <see cref="int"/>.
        ///
        /// Possible Win32 errors:
        /// ERROR_ACCESS_DENIED: The caller does not have sufficient permissions to perform the requested operation.
        /// ERROR_INVALID PARAMETER: hClientHandle is NULL or invalid, pInterfaceGuid is NULL, pReserved is not NULL, ppData is NULL, or pdwDataSize is NULL.
        /// ERROR_INVALID_HANDLE: The handle hClientHandle was not found in the handle table.
        /// ERROR_INVALID_STATE: OpCode is set to wlan_intf_opcode_current_connection and the client is not currently connected to a network.
        /// ERROR_NOT_ENOUGH_MEMORY: Failed to allocate memory for the query results.
        /// RPC_STATUS: Various error codes.
        /// </summary>
        /// <param name="opCode">The opcode of the parameter.</param>
        /// <returns>The integer value.</returns>
        private int GetInterfaceInt(WlanIntfOpcode opCode)
        {
            IntPtr valuePtr;
            int    valueSize;
            WlanOpcodeValueType opcodeValueType;

            WlanInterop.ThrowIfError(WlanInterop.WlanQueryInterface(client.clientHandle, info.interfaceGuid, opCode, IntPtr.Zero, out valueSize, out valuePtr, out opcodeValueType));

            try
            {
                return(Marshal.ReadInt32(valuePtr));
            }
            finally
            {
                WlanInterop.WlanFreeMemory(valuePtr);
            }
        }