对于这样编组的函数:
/*************************************************
* DWORD WINAPI WlanHostedNetworkSetProperty(
* _In_ HANDLE hClientHandle,
* _In_ _WLAN_HOSTED_NETWORK_OPCODE OpCode,
* _In_ DWORD dwDataSize,
* _In_ PVOID pvData,
* _Out_opt_ P_WLAN_HOSTED_NETWORK_REASON pFailReason,
* _Reserved_ PVOID pvReserved
* );
*************************************************/
[DllImport("Wlanapi.dll", SetLastError = true)]
public static extern UInt32 WlanHostedNetworkSetProperty(
[In] IntPtr hClientHandle,
[In] _WLAN_HOSTED_NETWORK_OPCODE OpCode,
[In] UInt32 dwDataSize,
[In] IntPtr pvData,
[Out] out _WLAN_HOSTED_NETWORK_REASON pFailReason,
[In, Out] IntPtr pvReserved
);
微软文档说,当我通过
_WLAN_HOSTED_NETWORK_OPCODE._WLAN_HOSTED_NETWORK_OPCODE_enable
作为OpCode的参数, pvData的值应该是一个指向布尔值的指针。
这是该函数的文档,
但我不知道如何让 IntPtr 指向布尔值?
是否应该以与我将指向结构的指针作为pvData传递时类似的方式完成:
int size = Marshal.SizeOf(settings); //*settings* is a struct with some data
IntPtr pSettings = Marshal.AllocHGlobal(size);
Marshal.StructureToPtr(settings, pSettings, true);
/* use the IntPtr */
Marshal.FreeHGlobal(pSettings);
但相反,我编组布尔值?或者有没有更简单的方法?
感谢所有可爱的人的帮助。