在写一个程序,需要在主程序中打开word、excel等office文档,我们计划使用setParent的方法将打开的Office程序的宿舍窗口改为我们的应用程序,实现窗口劫持。
用普通的office,实现起来没有问题,考虑该程序将在平板上部署,因此想通过office for mobile来实现,但运行起来不能获取office应用程序的实例,是不是因为office for mobile运行在沙盒里的,外部程序不能对它操作?或者有什么其他解决方法?
大致代码如下:
Process p = Process.Start("1.docx");
Thread.Sleep(1000); // Allow the process to open it's window
SetParent(p.MainWindowHandle, this.Handle);
报错是在SetParent时不能获取p实例