Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // 解决方案1.AutomatePowerPoint 演示了自动化的Microsoft PowerPoint
            // 应用程序通过使用Microsoft PowerPoint主互操作程序集(PIA),和显
            // 式地将每一个COM存取器赋予一个新的变量(这些变量需要在程序结束时
            // 显式的调用Marshal.FinalReleaseComObject方法来释放它)。
            Solution1.AutomatePowerPoint();

            Console.WriteLine();

            // 解决方案2.AutomatePowerPoint 演示了自动化Microsoft PowerPoint应
            // 用程序通过使用Microsoft PowerPoint PIA,并在自动化功能函数弹出栈
            // 后(在此时的RCW对象都是不可达的)就开始强制一次垃圾回收来清理RCW
            // 对象和释放COM对象。
            Solution2.AutomatePowerPoint();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // Solution1.AutomatePowerPoint demonstrates automating Microsoft
            // PowerPoint application by using Microsoft PowerPoint PIA and
            // explicitly assigning each COM accessor object to a new
            // varaible that you would explicitly call
            // Marshal.FinalReleaseComObject to release it at the end.
            Solution1.AutomatePowerPoint();

            Console.WriteLine();

            // Solution2.AutomatePowerPoint demonstrates automating Microsoft
            // PowerPoint application by using Microsoft PowerPoint PIA and
            // forcing a garbage collection as soon as the automation function
            // is off the stack (at which point the RCW objects are no longer
            // rooted) to clean up RCWs and release COM objects.
            Solution2.AutomatePowerPoint();
        }