[Winpcap-bugs] The function PacketGetAdapterNames can not return
the adapters' name
勇 相
mailtopaul2003 at yahoo.com.cn
Sun Jan 6 01:13:02 GMT 2008
I'm trying to use C#. In my program, I tried to call
the function which called PacketGetAdapterNames in
packet.dll, the function could return true, and the
param which called BufferSize was changed, but the
adapternames wasn't changed. The following is my code:
public partial class Form1 : Form
{
[DllImport("packet.dll",EntryPoint="PacketGetAdapterNames",CharSet=CharSet.Ansi)]
public static extern bool
PacketGetAdapterNames([MarshalAs(UnmanagedType.LPStr)]string
sStr, ref int BufferSize);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender,
EventArgs e)
{
bool b = false;
int length = 5;
string an = new string('0',length);
b = PacketGetAdapterNames(an, ref length);
NetworkInterface[] ni =
NetworkInterface.GetAllNetworkInterfaces();
label1.Text = an;
}
}
After runing, the variables b is true, and the length
is 242, the an is still "00000". What's wrong with my
code, please help me, thanks!
___________________________________________________________
雅虎邮箱传递新年祝福,个性贺卡送亲朋!
http://cn.mail.yahoo.com/gc/index.html?entry=5&souce=mail_mailletter_tagline
More information about the Winpcap-bugs
mailing list