From below link:

Creating a COM object in .Net based on its ProgID

 

 

/// <summary>
/// Creates a COM object given it's ProgID.
/// </summary>
/// <param name="sProgID">The ProgID to create</param>
/// <returns>The newly created object, or null on failure.</returns>
public static object COMCreateObject (string sProgID)
{
// We get the type using just the ProgID
Type oType = Type.GetTypeFromProgID (sProgID);
	if (oType != null)
{
return Activator.CreateInstance(oType);
}
	return null;
}

 

 

posted on 2009-11-23 15:51  xiaxi  阅读(265)  评论(0编辑  收藏  举报