/// <summary>
/// 以太网卡的名称
/// </summary>
private static string EtherCardName = string.Empty;
private const int OPEN_EXISTING = 3;
private const int FILE_ATTRIBUTE_NORMAL = 0x80;
private const int INVALID_HANDLE_VALUE = -1;
private const int IOCTL_NDIS_REBIND_ADAPTER = 1507374;
private const int IOCTL_NDIS_GET_ADAPTER_NAMES = 1507386;
[DllImport("Coredll.dll", EntryPoint = "CreateFile")]
private static extern int CreateFile(
string lpFileName,
int dwDesiredAccess,
int dwShareMode,
int lpSecurityAttributes,
int dwCreationDisposition,
int dwFlagsAndAttributes,
int hTemplateFile
);
[DllImport("Coredll.dll", EntryPoint = "DeviceIoControl")]
private static extern int DeviceIoControl(
int hDevice,
int dwIoControlCode,
string lpInBuffer,
int nInBufferSize,
string lpOutBuffer,
int nOutBufferSize,
int lpBytesReturned,
int lpOverlapped
);
[DllImport("Coredll.dll", EntryPoint = "DeviceIoControl")]
private static extern int DeviceIoControl2(
int hDevice,
int dwIoControlCode,
string lpInBuffer,
int nInBufferSize,
string lpOutBuffer,
int nOutBufferSize,
ref int lpBytesReturned,
int lpOverlapped
);
[DllImport("Coredll.dll", EntryPoint = "CloseHandle")]
private static extern int CloseHandle(int hObject);