ProgrammingChapter —7
266 700Series Color MobileComputer User’s Manual
Network Selection APIs
The Network Selection APIs change the network adapter configuration
programmatically.Both drivers support the sameIOCTL function num-
bers for loading and unloading the drivers.
Loading and unloading of the 802.11b or 802.11b/g driver is performed
by the FWL1: device in the system by performi ngD eviceIOControl() calls
to the driver.
Loading andunloading of the driver for the built-in Ethernet adapter is
performed bythe SYI1: device in the system by performing
DeviceIOControl()calls to the driver.
SFor loading an NDIS driver associated with an adapter, the IO CTL is
IOCTL_LOAD_NDIS_MINIPORT.
SFor unloading NDIS drivers associated with an adapter the I OCTL is
IOCTL_UNLOAD_NDIS_MINIPORT.
Example
#include <winioctl.h>
#include “sysio.h”
void DoLoad(int nDevice) {
LPTSTR devs[] = { _T(“SYI1:”), _T(“FWL1:”) };
HANDLE hLoaderDev;
DWORD bytesReturned;
hLoaderDev = CreateFile(devs[nDevice], GENERIC_READ|GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, 0, NULL);
if (hLoaderDev != INVALID_HANDLE_VALUE) {
if (!DeviceIoControl( hLoaderDev, IOCTL_LOAD_NDIS_MINIPORT, NULL, -1, NULL, 0,
&bytesReturned, NULL)){
MessageBox(NULL, TEXT(“SYSIO IoControl Failed”), TEXT(“Network
loader”),MB_ICONHAND);
if (hLoaderDev!=INVALID_HANDLE_VALUE) CloseHandle(hLoaderDev);
hLoaderDev = INVALID_HANDLE_VALUE; // bad handle
}else {
CloseHandle(hLoaderDev);
}
}
}
void DoUnload(int nDevice) {
LPTSTR devs[] = { _T(“SYI1:”), _T(“FWL1:”) };
HANDLE hLoaderDev;
DWORD bytesReturned;
hLoaderDev = CreateFile(devs[nDevice], GENERIC_READ|GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, 0, NULL);
if (hLoaderDev != INVALID_HANDLE_VALUE) {
if (!DeviceIoControl( hLoaderDev, IOCTL_UNLOAD_NDIS_MINIPORT, NULL, -1, NULL, 0,
&bytesReturned, NULL)){
MessageBox(NULL, TEXT(“SYSIO IoControl Failed”),TEXT(“Network
loader”),MB_ICONHAND);
if (hLoaderDev!=INVALID_HANDLE_VALUE) CloseHandle(hLoaderDev);
hLoaderDev = INVALID_HANDLE_VALUE; // bad handle
}else {
CloseHandle(hLoaderDev);
}
}
}