标题: 对已打开的WORD文档进行操作的问题 [打印本页] 作者: pepsl179 时间: 2017-3-23 16:42 标题: 对已打开的WORD文档进行操作的问题 using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Threading.Tasks;
namespace MultipleConnect
{
public class PmConnect
{
[DllImport("ole32.dll")]
static extern int CreateBindCtx(uint reserved, out IBindCtx ppbc);
[DllImport("ole32.dll")]
public static extern void GetRunningObjectTable(int reserved, out IRunningObjectTable prot);
private List<object> GetRunningInstances(string[] progIds)
{
List<string> clsIds = new List<string>();
foreach (string progId in progIds)
{
Type type = Type.GetTypeFromProgID(progId);
if (type != null)
clsIds.Add(type.GUID.ToString().ToUpper());
}
IRunningObjectTable Rot = null;
GetRunningObjectTable(0, out Rot);
if (Rot == null)
return null;