其实这个博友写得差不多了http://www.cnblogs.com/lipan/archive/2013/05/15/3080275.html
里面提供大部分代码,没有提供源代码,小弟就拷贝过来调试修改一下。