Ref: "Ap1400ProgGuide1_2.docx" Page 36 of 42
Document Revision: “1.2”
Document Date: “9 Apr. 2013”
CloseDevice
Closes and releases a device and assoc
int WINAPI CloseDevice(int *pHandle);
Closes a device and releases the resources associated with the device. Once
closed the handle is invalidated and should be discarded.
phandle – Pointer to the handle of an open device. This handle must have been
issued by a previous call to OpenDevice.
ERROR_SUCCESS if successfully closed, otherwise the value is set to the system
error code.
//Check range prior to call
if(CloseDevice(&ihandle)!=ERROR_SUCCESS)
{
CString csError;
csError.Format(_T(“Close device failed. R/C=%d.”),
GetLastError());
AfxMessageBox(csError,MB_ICONSTOP|MB_OK);
return;
}
//Device has been successfully closed
TRACE(_T(“Device close success. \n”));