Network selection apis, Example – Intermec 700 User Manual

Page 290

Advertising
background image

Programming

Chapter

7

266

700 Series Color Mobile Computer User’s Manual

Network Selection APIs

The Network Selection APIs change the network adapter configuration
programmatically. Both drivers support the same IOCTL 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 performing DeviceIOControl() calls
to the driver.
Loading and unloading of the driver for the built-in Ethernet adapter is
performed by the SYI1: device in the system by performing
DeviceIOControl() calls to the driver.

S For loading an NDIS driver associated with an adapter, the IOCTL is

IOCTL_LOAD_NDIS_MINIPORT.

S For unloading NDIS drivers associated with an adapter the IOCTL 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);

}

}

}

Advertising