답변

1

ossvcs.dll에서 GetDeviceListChangeRadioState을 호출해야합니다. 실제로이 작업을 수행하는 코드는 SO 게시물의 경우 약간 길기 때문에 해결할 수 있도록 남겨 두겠습니다. 몹시 어렵지 않습니다. (C code here이 있고 C# code on CodeProject도 있습니다. 사용하지 않았습니다. 그래서 YMMV).

또 다른 대안은 이미 랩핑 된 SDF에서 Radios 클래스를 사용하는 것입니다.

2

첫째 :이 DLL을

[DllImport("ossvcs.dll", EntryPoint = "#276", CharSet = CharSet.Unicode)] 
    private static extern uint GetWirelessDevice(ref IntPtr pDevice, int pDevVal); 

    [DllImport("ossvcs.dll", EntryPoint = "#273", CharSet = CharSet.Unicode)] 
    private static extern uint ChangeRadioState(ref RDD pDevice, int dwState, int saveAction); 

    [DllImport("ossvcs.dll", EntryPoint = "#280", CharSet = CharSet.Unicode)] 
    private static extern uint FreeDeviceList(IntPtr pDevice); 

을 가져 오기 그리고 여기뿐만 아니라 당신을 위해 작동해야 모토로라 MC65을 위해 사용하는 코드의 복사본입니다.
[StructLayout(LayoutKind.Auto)] 
    struct RADIODEVSTATE 
    { 
     public const int RADIODEVICES_ON = 1; 
     public const int RADIODEVICES_OFF = 0; 
    } 

    /* 
    typedef enum _RADIODEVTYPE 
    { 
     RADIODEVICES_MANAGED = 1, 
     RADIODEVICES_PHONE, 
     RADIODEVICES_BLUETOOTH, 
    } RADIODEVTYPE; 
    */ 
    [StructLayout(LayoutKind.Auto, CharSet = CharSet.Unicode)] 
    struct RADIODEVTYPE 
    { 
     public const int RADIODEVICES_MANAGED = 1; 
     public const int RADIODEVICES_PHONE = 2; 
     public const int RADIODEVICES_BLUETOOTH = 3; 
    } 

    /* 
    typedef enum _SAVEACTION 
    { 
     RADIODEVICES_DONT_SAVE = 0, 
     RADIODEVICES_PRE_SAVE, 
     RADIODEVICES_POST_SAVE, 
    } SAVEACTION; 
    */ 
    [StructLayout(LayoutKind.Auto, CharSet = CharSet.Unicode)] 
    struct SAVEACTION 
    { 
     public const int RADIODEVICES_DONT_SAVE = 0; 
     public const int RADIODEVICES_PRE_SAVE = 1; 
     public const int RADIODEVICES_POST_SAVE = 2; 
    } 

    /* 
    struct RDD 
    { 
     RDD() : pszDeviceName(NULL), pNext(NULL), pszDisplayName(NULL) {} 
     ~RDD() { LocalFree(pszDeviceName); LocalFree(pszDisplayName); } 
     LPTSTR pszDeviceName; // Device name for registry setting. 
     LPTSTR pszDisplayName; // Name to show the world 
     DWORD dwState;  // ON/off/[Discoverable for BT] 
     DWORD dwDesired;  // desired state - used for setting registry etc. 
     RADIODEVTYPE DeviceType;   // Managed, phone, BT etc. 
     RDD * pNext; // Next device in list 
    }; //radio device details 
    */ 
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 
    struct RDD 
    { 
     [MarshalAs(UnmanagedType.LPTStr)] 
     public string pszDeviceName; 

     [MarshalAs(UnmanagedType.LPTStr)] 
     public string pszDisplayName; 

     public uint dwState; 
     public uint dwDesired; 
     public int DeviceType; 
     public IntPtr pNext; 
    } 


    private static bool SetDeviceState(int dwDevice, int dwState) 
    { 
     var pDevice = new IntPtr(0); 

     //Get the first wireless device 
     var result = GetWirelessDevice(ref pDevice, 0); 

     if (result != 0) 
      return false; 

      //While we're still looking at wireless devices 
      while (pDevice != IntPtr.Zero) 
      { 
       //Marshall the pointer into a C# structure 
       var device = (RDD)System.Runtime.InteropServices.Marshal.PtrToStructure(pDevice, typeof(RDD)); 

       //If this device is the device we're looking for 
       if (device.DeviceType == dwDevice) 
       { 
        //Change the state of the radio 
        result = ChangeRadioState(ref device, dwState, SAVEACTION.RADIODEVICES_PRE_SAVE); 
       } 

       //Set the pointer to the next device in the linked list 
       pDevice = device.pNext; 
      } 

      //Free the list of devices 
      FreeDeviceList(pDevice); 

     //Turning off radios doesn't correctly report the status, so return true anyway. 
     return result == 0 || dwState == RADIODEVSTATE.RADIODEVICES_OFF; 
    } 

그리고

단순히 방법에 따라 호출 전화를 끄려면 :

/// <summary> 
    /// Disables the phone radio on device 
    /// </summary> 
    public void DisablePhoneRadio() 
    { 
      SetDeviceState(RADIODEVTYPE.RADIODEVICES_PHONE, RADIODEVSTATE.RADIODEVICES_OFF); 
    } 

그래서 단지 필요 조건 어떤 문을 사용하고 사용하지 않도록 설정해야하고, 전화를 사용할 때마다 DisablePhoneRadio()를 호출 라디오 단순히 SWAT과 같이 RADIODEVSTATE.RADIODEVICES_ON와 RADIODEVSTATE.RADIODEVICES_OFF 아웃 :이 도움이

/// <summary> 
    /// Enables the phone radio on device 
    /// </summary> 
    public void EnablePhoneRadio() 
    { 
      SetDeviceState(RADIODEVTYPE.RADIODEVICES_PHONE, RADIODEVSTATE.RADIODEVICES_ON); 
    } 

희망!