【发布时间】:2016-01-09 14:30:10
【问题描述】:
您知道如何获取应用程序 ID(在给定示例中为“Word.Application”)吗?如果我需要 Excel 怎么办?还是 InDesing?
object word;
try
{
word = System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
//If there is a running Word instance, it gets saved into the word variable
}
catch (COMException)
{
//If there is no running instance, it creates a new one
Type type = Type.GetTypeFromProgID("Word.Application");
word = System.Activator.CreateInstance(type);
}
【问题讨论】:
-
你所说的应用程序ID是什么意思?
-
你从哪里开始?那就是:你有什么信息想从中获得名字? (PS。“Application Id”在COM中已经有含义:它是GUID的另一种用法,这些名称通常称为“program ids,或更常见的progid。