Regular files are scanned by using the kaveScanFile function. Except for the parameters common for all scanning functions, the kaveScanFile function requires a name of the file to scan. It is specified by using the Universal Naming Convention (UNC) path. You can also use the \\?\ prefix for local and UNC paths when working with Win32® API file I/O to avoid path string parsing by Windows API. This convention turns the automatic path expansion performed by APIs off directly sending the path to the file system thus allowing to construct extended-length paths. If necessary, you can access devices by using the \\.\ prefix.
Using UNC path and path constructed with prefixes that turn off automatic path expansion and allow for direct opening of devices is only supported on Windows platform.
Using relative paths is not recommended!
The example below demonstrates usage of the kaveScanFile function with standard local path.
Example: // The kaveScanFile function usage unsigned long dwScanningMode = KAV_O_M_PACKED | KAV_O_M_ARCHIVED | KAV_O_M_MAILPLAIN | KAV_O_M_HEURISTIC_LEVEL_SHALLOW;
KAV_RESULT result = KAV_S_R_NONSCANNED; unsigned long dwTaskID = 0; void *ctx;
HRESULT hr = kaveScanFile( "c:\\Test\\eicar.com", 7, dwScanningMode, KAV_CLEAN_SKIP, INFINITE, ctx, &dwTaskID, &result ); |
The following parameter values of the kaveScanFile function are specified in the example:
"c:\\Test\\eicar.com"—full path to the file to scan.7—scanning priority.dwScanningMode—scanning mode which is set to KAV_O_M_PACKED | KAV_O_M_ARCHIVED | KAV_O_M_MAILPLAIN | KAV_O_M_HEURISTIC_LEVEL_SHALLOW. This means that compressed executable files, archives and e-mail messages scanning is on, as well as using heuristic code analyzer.KAV_CLEAN_SKIP—cleaning mode. This particular value means that if the "c:\\Test\\eicar.com" file contains a malware, the application will try to disinfect the file. If disinfection fails, the scan task is skipped.INFINITE—scan timeout. In this example, scanning of the specified file will take as much time as necessary.ctx—user context that can be used by callback functions.dwTaskID—scan ID that can be used either to cancel this scan task or by a callback function. The KAV SDK will automatically fill this out parameter with the non-zero value.&result—pointer to the scanning result. In this example it is not NULL, and the scanning is synchronous.