Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用wlan api打开收音机_C#_Windows_Interop_Wlanapi - Fatal编程技术网

C# 使用wlan api打开收音机

C# 使用wlan api打开收音机,c#,windows,interop,wlanapi,C#,Windows,Interop,Wlanapi,我需要在C.中使用wlanapi关闭无线收音机。 我能关掉收音机,但不能打开。 这是我的密码: WLAN_PHY_RADIO_STATE wlan_intf_opcode_radio_state = new WLAN_PHY_RADIO_STATE(); wlan_intf_opcode_radio_state.dwPhyIndex = 0; // TODO : can change ??? wlan_intf_opcode_radio_state.dot11HardwareRadioState

我需要在
C.
中使用wlanapi关闭无线收音机。 我能关掉收音机,但不能打开。 这是我的密码:

WLAN_PHY_RADIO_STATE wlan_intf_opcode_radio_state = new WLAN_PHY_RADIO_STATE();
wlan_intf_opcode_radio_state.dwPhyIndex = 0; // TODO : can change ???
wlan_intf_opcode_radio_state.dot11HardwareRadioState = DOT11_RADIO_STATE.dot11_radio_state_on;// ignored in fact, according to http://msdn.microsoft.com/en-us/library/windows/desktop/ms706791(v=vs.85).aspx 
wlan_intf_opcode_radio_state.dot11SoftwareRadioState = DOT11_RADIO_STATE.dot11_radio_state_on;

radioStatePtr = Marshal.AllocHGlobal(Marshal.SizeOf(wlan_intf_opcode_radio_state));
Marshal.StructureToPtr(wlan_intf_opcode_radio_state, radioStatePtr, false);

if (WlanEnumInterfaces(handle, IntPtr.Zero,
              out ppInterfaceList) == ERROR_SUCCESS)
{

    interfaceList = new WLAN_INTERFACE_INFO_LIST(ppInterfaceList);



    for (int i = 0; i < interfaceList.dwNumberofItems; i++)
    {
        Guid pInterfaceGuid = ((WLAN_INTERFACE_INFO)interfaceList.InterfaceInfo[0]).InterfaceGuid;

        if (WlanSetInterface(handle, ref pInterfaceGuid, WLAN_INTF_OPCODE.wlan_intf_opcode_radio_state, dataSize, ref ptr, IntPtr.Zero) == ERROR_SUCCESS)
            MessageBox.Show("yes");
        else MessageBox.Show("Some Issue");

    }
}
一切进展顺利,我是说wlansetinterface函数返回
错误\u成功
,但我的电脑没有打开收音机。请帮助我错过了什么


我暂停

您的设备上运行的是什么操作系统?代码和链接是关于Windows7的,而不是Compact框架。对于CF,请使用OpenNetCF(ie)Hey@josef。。。谢谢你的回复。我正在用C#在windows7中寻找解决方案。那么为什么您的代码与您提供的链接不匹配呢?@ErikPhilips我只使用了相同的代码。。。错误打印调试没有太大差异
[DllImport("wlanapi.dll", SetLastError = true)]
public static extern uint WlanSetInterface(IntPtr hClientHandle, ref Guid      pInterfaceGuid, WLAN_INTF_OPCODE OpCode, uint dwDataSize, ref  IntPtr pData, IntPtr pReserved);