A
Abhi
Hi,
I am trying to use the native WinCE API WZCEnumInterfaces using
interop in C# .NET compact framework. I have to develop this without
the OpenNetCF wrapper. But whenever I call the function, I get the
exception "System.NotSupportedException". I looked at the help page
for this exception and I think I have taken care of all the possible
causes for the exception. Could anyone please let me know anything
that I could be doing wrong. Please find my code below:
[StructLayout(LayoutKind.Sequential)]
struct INTF_KEY_ENTRY
{
[MarshalAs(UnmanagedType.LPWStr)]
public string wszGuid;
}
[StructLayout(LayoutKind.Sequential)]
struct INTFS_KEY_TABLE
{
public uint dwNumIntfs;
public IntPtr pIntfs; //This is a pointer to
INTF_KEY_ENTRY in the native c++
}
[DllImport("wzcsapi.dll", SetLastError = true)]
private static extern ulong WZCEnumInterfaces(string pSrvAddr,
ref INTFS_KEY_TABLE pIntfs);
/// <summary>
/// find the first wireless network cards
/// </summary>
public void GetFirstWirelessNetworkCard()
{
INTFS_KEY_TABLE IntfsTable = new
INTFS_KEY_TABLE();
IntfsTable.dwNumIntfs = 0;
IntfsTable.pIntfs =
Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)) *
(int)IntfsTable.dwNumIntfs);
ulong dwStatus = 0;
try
{
dwStatus = WZCEnumInterfaces(null , ref IntfsTable);
}
catch(Exception e)
{
int errorNum = Marshal.GetLastWin32Error();
MessageBox.Show(e.Message + " Error: " + errorNum,
"Fatal Error!");
return;
}
}
I am trying to use the native WinCE API WZCEnumInterfaces using
interop in C# .NET compact framework. I have to develop this without
the OpenNetCF wrapper. But whenever I call the function, I get the
exception "System.NotSupportedException". I looked at the help page
for this exception and I think I have taken care of all the possible
causes for the exception. Could anyone please let me know anything
that I could be doing wrong. Please find my code below:
[StructLayout(LayoutKind.Sequential)]
struct INTF_KEY_ENTRY
{
[MarshalAs(UnmanagedType.LPWStr)]
public string wszGuid;
}
[StructLayout(LayoutKind.Sequential)]
struct INTFS_KEY_TABLE
{
public uint dwNumIntfs;
public IntPtr pIntfs; //This is a pointer to
INTF_KEY_ENTRY in the native c++
}
[DllImport("wzcsapi.dll", SetLastError = true)]
private static extern ulong WZCEnumInterfaces(string pSrvAddr,
ref INTFS_KEY_TABLE pIntfs);
/// <summary>
/// find the first wireless network cards
/// </summary>
public void GetFirstWirelessNetworkCard()
{
INTFS_KEY_TABLE IntfsTable = new
INTFS_KEY_TABLE();
IntfsTable.dwNumIntfs = 0;
IntfsTable.pIntfs =
Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)) *
(int)IntfsTable.dwNumIntfs);
ulong dwStatus = 0;
try
{
dwStatus = WZCEnumInterfaces(null , ref IntfsTable);
}
catch(Exception e)
{
int errorNum = Marshal.GetLastWin32Error();
MessageBox.Show(e.Message + " Error: " + errorNum,
"Fatal Error!");
return;
}
}