/// <summary> /// Initialize ClamWinQuarantine /// </summary> /// <returns></returns> public static bool Open(string ProgramFolder) { lock( MainLock ) { if (Opened) { // Already opened return false; } NewItemAddedEvent = Win32API.CreateEvent((IntPtr)0 , false, false, "ClamWinQuarantineNewItemAddedEvent"); if (NewItemAddedEvent == (IntPtr)Win32API.INVALID_HANDLE_VALUE) { return false; } QuarantinePath = ProgramFolder + "\\Quarantine\\"; try { DirectoryInfo di = new DirectoryInfo(QuarantinePath); if (!di.Exists) { di.Create(); } } catch { } Terminate = false; SkipCurrentItem = false; Opened = true; } CompressResult = Compress.BeginInvoke(null, null); return true; }
/// <summary> /// Opens service pipe /// </summary> /// <returns>true if success, false if failed</returns> public static bool Open(IntPtr handle) { /* * System.ServiceProcess.ServiceController controller = null; * try * { * controller = new System.ServiceProcess.ServiceController("ClamWind"); * * if (controller.Status != System.ServiceProcess.ServiceControllerStatus.Running) * { * controller.Start(); * * controller.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Running, * new TimeSpan(0, 0, 0, 0, 35 * 1000) * ); * if (controller.Status != System.ServiceProcess.ServiceControllerStatus.Running) * { * throw 0; * } * } * } * catch * { * return false; * } * finally * { * controller.Close(); * } */ varFilterJobsUpdatedEvent = Win32API.CreateEvent((IntPtr)0, false, false, "FilterListenerJobsUpdated"); varStopFilterListening = Win32API.CreateEvent((IntPtr)0, false, false, "StopFilterListening"); FilterFakeScan = new ClamWinScan(ClamWinScanner.FakeScanID); IntPtr[] listeners = new IntPtr[1]; listeners[0] = handle; FilterFakeScan.StartFilterListening(listeners); return(true); }