DM9000冷启动,不需要重新编译内核,以下C#程序在WINCE6.0系统下运行:
const Byte IO_CTL_DM9000_RESET = 0x14;
private const int IOCTL_NDIS_REBIND_ADAPTER = 1507374;
private const int IOCTL_NDIS_GET_ADAPTER_NAMES = 1507386;
private const string EtherCardFileName = "NDS0:";
private const int FILE_ATTRIBUTE_NORMAL = 0x80;
private static string EtherCardName = "DM9CE1\0";
[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 = "CloseHandle")]
private static extern int CloseHandle(int hObject);
public static bool resetDM9000()
{
int hNdis = CreateFile(EtherCardFileName, 0, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,INVALID_HANDLE_VALUE);
if (hNdis == INVALID_HANDLE_VALUE)
{
return false;
}
// Send the device command.
if (DeviceIoControl(hNdis, IOCTL_NDIS_REBIND_ADAPTER, EtherCardName, EtherCardName.Length * 2 + 2, null, 0, 0, 0) == 0)
{
return false;
}
CloseHandle(hNdis);
return true;
}
阅读(917) | 评论(0) | 转发(0) |