M
mich1985
Hello,
i try to use the following function to get avaiable wifi nics.
C/C++ declaration:
//---------------------------------------
// [P]INTF_ENTRY: describes the key info for one interface
// this is used in conjunction with [P]INTFS_KEY_TABLE and
WZCEnumInterfaces
typedef struct
{
LPWSTR wszGuid;
} INTF_KEY_ENTRY, *PINTF_KEY_ENTRY;
//---------------------------------------
// [P]INTFS_KEY_TABLE: describes the table of key info for all
interfaces
// this is used in conjunction with [P]INTF_KEY_ENTRY and
WZCEnumInterfaces
typedef struct
{
DWORD dwNumIntfs;
PINTF_KEY_ENTRY pIntfs;
} INTFS_KEY_TABLE, *PINTFS_KEY_TABLE;
// Parameters:
// pSrvAddr
// [in] WZC Server to contact
// pIntf
// [out] table of key info for all interfaces
// Returned value:
// Win32 error code
DWORD
WZCEnumInterfaces(
LPWSTR pSrvAddr,
PINTFS_KEY_TABLE pIntfs);
my C# Version:
[StructLayout(LayoutKind.Sequential)]
public struct INTFS_KEY_TABLE
{
public uint dwNumIntfs;
//public INTF_KEY_ENTRY pIntfs;
public IntPtr pIntfs;
}
[StructLayout(LayoutKind.Sequential)]
public struct INTF_KEY_ENTRY
{
public string wszGuid;
}
[DllImport("WZCSAPI.dll")]
public static extern uint WZCEnumInterfaces(string pSvrAddr,
ref INTFS_KEY_TABLE myTab);
My Program:
uint retValue = 0;
INTFS_KEY_TABLE IntfsTable = new INTFS_KEY_TABLE();
INTF_KEY_ENTRY IntfsEntry = new INTF_KEY_ENTRY();
IntfsEntry.wszGuid = null;
IntfsTable.dwNumIntfs = 0;
Marshal.StructureToPtr(IntfsEntry, IntfsTable.pIntfs,
false);
retValue = WZCEnumInterfaces("", ref IntfsTable);
etc...
On StructureToPtr it crashes. Why? Are there any faults in the
declaration part?
Best Regards,
Florian
i try to use the following function to get avaiable wifi nics.
C/C++ declaration:
//---------------------------------------
// [P]INTF_ENTRY: describes the key info for one interface
// this is used in conjunction with [P]INTFS_KEY_TABLE and
WZCEnumInterfaces
typedef struct
{
LPWSTR wszGuid;
} INTF_KEY_ENTRY, *PINTF_KEY_ENTRY;
//---------------------------------------
// [P]INTFS_KEY_TABLE: describes the table of key info for all
interfaces
// this is used in conjunction with [P]INTF_KEY_ENTRY and
WZCEnumInterfaces
typedef struct
{
DWORD dwNumIntfs;
PINTF_KEY_ENTRY pIntfs;
} INTFS_KEY_TABLE, *PINTFS_KEY_TABLE;
// Parameters:
// pSrvAddr
// [in] WZC Server to contact
// pIntf
// [out] table of key info for all interfaces
// Returned value:
// Win32 error code
DWORD
WZCEnumInterfaces(
LPWSTR pSrvAddr,
PINTFS_KEY_TABLE pIntfs);
my C# Version:
[StructLayout(LayoutKind.Sequential)]
public struct INTFS_KEY_TABLE
{
public uint dwNumIntfs;
//public INTF_KEY_ENTRY pIntfs;
public IntPtr pIntfs;
}
[StructLayout(LayoutKind.Sequential)]
public struct INTF_KEY_ENTRY
{
public string wszGuid;
}
[DllImport("WZCSAPI.dll")]
public static extern uint WZCEnumInterfaces(string pSvrAddr,
ref INTFS_KEY_TABLE myTab);
My Program:
uint retValue = 0;
INTFS_KEY_TABLE IntfsTable = new INTFS_KEY_TABLE();
INTF_KEY_ENTRY IntfsEntry = new INTF_KEY_ENTRY();
IntfsEntry.wszGuid = null;
IntfsTable.dwNumIntfs = 0;
Marshal.StructureToPtr(IntfsEntry, IntfsTable.pIntfs,
false);
retValue = WZCEnumInterfaces("", ref IntfsTable);
etc...
On StructureToPtr it crashes. Why? Are there any faults in the
declaration part?
Best Regards,
Florian