EaseFilter Demo Project
FilterDriverService.cs
Go to the documentation of this file.
1 
3 //
4 // (C) Copyright 2012 EaseFilter Technologies Inc.
5 // All Rights Reserved
6 //
7 // This software is part of a licensed software product and may
8 // only be used or copied in accordance with the terms of that license.
9 //
11 
12 
13 using System;
14 using System.Collections.Generic;
15 using System.Linq;
16 using System.Text;
17 using System.Runtime.InteropServices;
18 
20 
22 {
23  public class FilterDriverService
24  {
25  public static bool StartFilterService(out string lastError)
26  {
27  //Purchase a license key with the link: http://www.easefilter.com/Order.htm
28  //Email us to request a trial key: info@FilterAPI.com //free email is not accepted.
29  string registerKey = "**************************************";
30 
31  bool ret = false;
32  try
33  {
34 
35  lastError = string.Empty;
36 
37  ret = FilterAPI.StartFilter((int)GlobalConfig.FilterConnectionThreads
38  , registerKey
39  , new FilterAPI.FilterDelegate(FilterCallback)
40  , new FilterAPI.DisconnectDelegate(DisconnectCallback)
41  , ref lastError);
42  if (!ret)
43  {
44  EventManager.WriteMessage(30, "StartFilter", EventLevel.Error, "Start filter service failed with error " + lastError);
45  return ret;
46  }
47 
48 
51 
52  EventManager.WriteMessage(102, "StartFilter", EventLevel.Information, "Start filter service succeeded.");
53  }
54  catch (Exception ex)
55  {
56  lastError = ex.Message;
57  EventManager.WriteMessage(104, "StartFilter", EventLevel.Error, "Start filter service failed with error " + ex.Message);
58  }
59 
60  return ret;
61  }
62 
63  static Boolean FilterCallback(IntPtr sendDataPtr, IntPtr replyDataPtr)
64  {
65  Boolean ret = true;
66 
67  try
68  {
69  FilterAPI.MessageSendData messageSend = new FilterAPI.MessageSendData();
70  messageSend = (FilterAPI.MessageSendData)Marshal.PtrToStructure(sendDataPtr, typeof(FilterAPI.MessageSendData));
71 
72  if (FilterAPI.MESSAGE_SEND_VERIFICATION_NUMBER != messageSend.VerificationNumber)
73  {
74  EventManager.WriteMessage(139, "FilterCallback", EventLevel.Error, "Received message corrupted.Please check if the MessageSendData structure is correct.");
75  return false;
76  }
77 
78 
79  return ret;
80  }
81  catch (Exception ex)
82  {
83  EventManager.WriteMessage(134, "FilterCallback", EventLevel.Error, "filter callback exception." + ex.Message);
84  return false;
85  }
86 
87  }
88 
89  static void DisconnectCallback()
90  {
91  EventManager.WriteMessage(82, "DisconnectCallback", EventLevel.Information, "filter service is disconnected.");
92  }
93 
94  }
95 }
static bool StartFilterService(out string lastError)
#define registerKey

Social Network


Services Overview

Architect, implement and test file system filter drivers for a wide range of functionality. We can offer several levels of assistance to meet your specific.

Contact Us

You are welcome to contact us for salse or partnership.

Sales: sales@easefilter.com
Support: support@easefilter.com
Info: info@easefilter.com