IOCTL_FARC_DEINIT

Purpose: deinitialization of the driver

Parameter:
IN:   -
OUT:  -

Comment:
This function must be called before performing a CloseHandle. All pending ReadFile- and WriteFile-requests will be cancelled and return to the caller. This function can take some time, before it succeeds.
You should always wait for the successful return, before closing the driverhandle!

Possible errors (see also Error codes):
E_FARC_INVALID_HANDLE

Example:
Note, that the following example is only a fragment. It is recommended, that the driver is opened in asynchronous mode and a handle to the driver is available.

OVERLAPPED overlapped;
DWORD read, err;
BOOL ret;

overlapped.Offset = 0;
overlapped.OffsetHigh = 0;
overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
 
...
ret = DeviceIoControl(drvhandle,
    IOCTL_FARC_DEINIT,
    NULL, 0,
    NULL, 0,
    &read, &overlapped);
if (!ret)
{
   err = GetLastError();
   if (err == E_FARC_PENDING)
   {
      ret = GetOverlappedResult(drvhandle, &overlapped, &read, TRUE);
      if (!ret)
      {
         err = GetLastError();
         // do errorhandling here
      }
      else
      {
         // Now you can do a CloseHandle
      }
   }
   else
   {
      // other error occured, perhaps wrong handle
   }
}
...

Programmer's Guide
Contents