Download the package "libclamox-win32" and
add references to "libclamox.dll" and "libclamoxcs.dll" to
your project. Your project output folder should contain Clamox libraries
and folders for virus database, temporary files and quarantined files :

// Clamox init Clamox.AgentConfig conf = new Clamox.AgentConfig(null, Clamox.Util.IsAdministrator()); String clamoxDir = Clamox.Util.getCurrentEnvPath() + "\\database";
// Database update int resultCode = -1; if (!Clamox.Freshclam.UpdateVirusDB(clamoxDir,conf.CurrentOptions, ref resultCode))
throw new Exception("Error : code = "+resultCode.ToString());
// Print virus database stats String version = "?"; String date = "?"; int signo = 0;
if (Clamox.Database.GetStats(clamoxDir, ref signo, ref version, ref date)) { Console.WriteLine("Version : " + version); Console.WriteLine("Date : " + date; Console.WriteLine("Signo : "+signo.ToString(); } else throw new Exception("Database not found");
// Load Clamox configuration and init engine conf.CurrentOptions.loadFromClamoxRegistry("default"); resultCode = -1; if (!Clamox.ClamavEngine.InitEngine(conf, ref resultCode)) throw new Exception("Clamav engine init failed code=" +
resultCode.ToString());
// Memory scan String virusName = ""; String notScanned = ""; resultCode = -1; int pid = -1; if (Clamox.ClamavEngine.ScanProcesses(ref virusName, ref resultCode, ref pid, ref notScanned)) { switch (resultCode) { case Clamox.Symbols.CL_VIRUS: Console.WriteLine("Scanned VIRUS : " + virusName); break; case Clamox.Symbols.CL_CLEAN: Console.WriteLine("Scanned SAFE"); break; default: Console.WriteLine("Scanned ERROR " + resultCode.ToString() +
" pid=" + pid.ToString()); break; } } else throw new Exception("Memory scan ERROR " + resultCode.ToString() + " pid=" + pid.ToString());
// File scan if (Clamox.ClamavEngine.ScanFile("path_of_the_file_to_scan", ref virusName, ref resultCode)) { switch (resultCode) { case Clamox.Symbols.CL_VIRUS: Console.WriteLine("Scanned VIRUS : " + virusName); break; case Clamox.Symbols.CL_CLEAN: Console.WriteLine("Scanned SAFE"); break; default: Console.WriteLine("Scanned ERROR code=" + resultCode.ToString()); break; } } else throw new Exception("File scan ERROR code=" + resultCode.ToString());
Clamox.ClamavEngine.FreeEngine();
|