如题,关于杀死Excel进程的文章很多,
可是都不是采用的后期绑定方式。
有没有哪位达人做过呀,我的代码如下:
object objApp_Late;
object objBook_Late;
object objBooks_Late;
object objSheets_Late;
object objSheet_Late;
object objRange_Late;
int t=0;
int ki=0;
System.Diagnostics.Process exp2 = null; // Get the class type and instantiate Excel.
Type objClassType; 
objClassType = Type.GetTypeFromProgID("Excel.Application");
objApp_Late = Activator.CreateInstance(objClassType);

//線程号取得
Object t2 = objApp_Late.GetType().InvokeMember( "Hwnd", BindingFlags.GetProperty,null, objApp_Late, null );
t = (int)t2;
ki=0;
.
.
.
.
GetWindowThreadProcessId(t,out ki);
exp2 =System.Diagnostics.Process.GetProcessById(ki);
exp2.Kill();以上代码在XP系统里没有问题,
但是win2000中运行通不过。
Object t2 = objApp_Late.GetType().InvokeMember( "Hwnd", BindingFlags.GetProperty,null, objApp_Late, null );
这一句出错。
估计是第一个参数“Hwnd”的问题。
可能是Xp和win2000的调用方式不一样。
但不知道应该怎么写。
有没有做过的呀?

解决方案 »

  1.   

    杀她干什么?为什么要杀她?你有什么权力杀她!
    Excel她容易吗!你为什么这么狠心要杀她!
    她为你做的还不够吗!
      

  2.   

    参考
    Office with .Net(二)之外传―――“彻底干净的”关闭Office程序 http://blog.joycode.com/kaneboy/archive/2005/11/04/66364.aspx
      

  3.   

    谢谢net_lover(【孟子E章】) 
    问题已解决。分已给啦,呵呵